Giter Site home page Giter Site logo

alvises / fppopover Goto Github PK

View Code? Open in Web Editor NEW
904.0 904.0 250.0 5.74 MB

FPPopover provides an alternative to the native iOS UIPopoverController, adding support for iPhone and additional opportunities to customize the look and feel of the popovers.

Home Page: http://www.poeticoding.com/fppopover-a-customizable-uipopovercontroller-for-iphone-and-ipad/

License: Other

C 0.89% Ruby 0.27% Objective-C 98.84%

fppopover's People

Contributors

alvises avatar daviad avatar ianisme avatar johnkdoe avatar lexrus avatar markrickert avatar psaccomani avatar romanr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fppopover's Issues

Remove white border on clear Views

Right now I am adding an UIView with "Clear" background in order to see the black background of the Popover, but there is a very visible white border around the view area.

Is this a feature or an issue?

FPPopover leak under ARC

Hi,

Using the Profiler tool I've noticed that the FPPopover view is not released after the popover is nil'ed or dismissed.

Opening FPPover on landscape doesn't assume contentSize

While on portrait if I set the contentSize to:

popover.contentSize = CGSizeMake(282.0f,260.0f);

It will have that size. If I open in landscape, it seems it doesn't do anything and it keeps the default size of (200,300)

Retain-Cycle Found

for example, self is an instance of class FPPopoverController

self-->self.view-->self._touchView-->_touchView._outsideBlock-->self

retain cycle

hello alvises,

i found that -(void)dealloc in FPPopoverController.m never been called, after some try & error . i think that is some kind of retain cycle issue. i make some dirty change so that -(void)dealloc will works.


-(id)initWithViewController:(UIViewController*)viewController
delegate:(id)delegate

find:
__block typeof (self) bself = self;
[_touchView setTouchedOutsideBlock:^{
[bself dismissPopoverAnimated:YES];
}];

relace:
__weak __typeof(&*self)weakSelf = self;
[_touchView setTouchedOutsideBlock:^{
[weakSelf dismissPopoverAnimated:YES];
}];

-(void)presentPopoverFromPoint:(CGPoint)fromPoint
find:
[self setupView];
self.view.alpha = 0.0;
[UIView animateWithDuration:0.2 animations:^{

    self.view.alpha = self.alpha;
}];

replace:
[self setupView];
self.view.alpha = 0.0;
__weak __typeof(&*self)weakSelf = self;
[UIView animateWithDuration:0.2 animations:^{

    weakSelf.view.alpha = self.alpha;
}];

-(void)dismissPopoverAnimated:(BOOL)animated completion:(FPPopoverCompletion)completionBlock

find:
[UIView animateWithDuration:0.2 animations:^{
self.view.alpha = 0.0;
} completion:^(BOOL finished) {
[self dismissPopover];
if (completionBlock)
completionBlock();
}];

replace:
__weak __typeof(&*self)weakSelf = self;
[UIView animateWithDuration:0.2 animations:^{
weakSelf.view.alpha = 0.0;
} completion:^(BOOL finished) {
[weakSelf dismissPopover];
if (completionBlock)
completionBlock();
}];

-(void)deviceOrientationDidChange:(NSNotification*)notification
find:
if (shouldResetView)
[UIView animateWithDuration:0.2 animations:^{
[self setupView];
}];

replace:
if (shouldResetView){
__weak __typeof(&*self)weakSelf = self;

    [UIView animateWithDuration:0.2 animations:^{
        [weakSelf setupView];
    }];
}

Fatal Exception NSInvalidArgumentException -[UIImage tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x2b3a69e0

0 ... CoreFoundation exceptionPreprocess + 162
3 CoreFoundation __forwarding
+ 392
4 CoreFoundation _CF_forwarding_prep_0 + 24
5 UIKit -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1554
6 UIKit -[UITableViewRowData rectForFooterInSection:] + 314
7 UIKit -[UITableViewRowData heightForTable] + 52
8 UIKit -[UITableView(_UITableViewPrivate) _updateContentSize] + 324
9 UIKit -[UITableView _rectChangedWithNewSize:oldSize:] + 256
10 UIKit -[UITableView setFrame:] + 224
11 DVAG-Cloud
FPPopoverView.m line 512
-[FPPopoverView setupViews]
12 DVAG-Cloud
FPPopoverView.m line 527
-[FPPopoverView setFrame:]
13 DVAG-Cloud
FPPopoverController.m line 556
-[FPPopoverController bestArrowDirectionAndFrameFromView:]
14 DVAG-Cloud
FPPopoverController.m line 183
-[FPPopoverController setupView]

In this case the contentRect has a negative size and I don't know where this came from :(

Subtitle: cell.detailTextLabel.text

Can the cells display subtitle? I had to attached myUITableViewController to a nib.

In the Storyboard I have the cell setup to show subtitle, however, when the popOver appears on the iPhone, only cell.textLabel.text is visible? cell.detailTextLabel.text is not appearing.

popover from tabBarItem?

I glanced over the code and it looks like adding popover from navigationBar/toolBar/tabBar isn't readily available. (since they are not Views)

I'm not sure if "new issue" is the right place to ask this.

Custom Cell Not Appearing Correctly

Hi I've add FPPopover to my project and got it working fine with a UITableView appearing inside the popover using the Standard UITableViewCell. When i changed to a Custom Cell, the cells are blank the UILabel doesn't appear, when i touch the cell im getting the correct readout in the log, which what the label should display. Also when i load the table normally not inside the popover the label is displayed correctly. Cant seem to figure out whats going wrong, any help would be much appreciated.

Gradient wrong for White Tint Popover

In FPPopoverView.m

else if(self.tint == FPPopoverWhiteTint)
{
colors[0] = colors[1] = colors[2] = 1.0;
colors[0] = colors[1] = colors[2] = 1.0;
colors[3] = colors[7] = 1.0;
}

Which leaves the the title bar uncolored in the popover.

It should be:

else if(self.tint == FPPopoverWhiteTint)
{
colors[0] = colors[1] = colors[2] = 1.0;
colors[3] = colors[4] = colors[5] = 1.0;
colors[6] = colors[7] = 1.0;
}

Seems like a minor typo, so I didn't want to do a merge request for it.

Ruben

Small bug when using NoArrow and title = Nil

In FPPopoverView, -(void)setupViews, the contentRect calculation is wrong when arrorDirection is NoArrow combined with no title.

contentRect.origin = CGPointMake(10, 30);
contentRect.size = CGSizeMake(self.bounds.size.width-20, self.bounds.size.height-40);

Should be:
contentRect.origin = CGPointMake(10, 10);
contentRect.size = CGSizeMake(self.bounds.size.width-20, self.bounds.size.height-20);

Support for multiple windows & subviews

Hello,

Thanks for this library, it's awesome!

I found an issue that if the app has multiple windows and subviews, the FPPopover is not being displayed on the visible view.

Checking the code I found that -(void)presentPopoverFromPoint:(CGPoint)fromPoint; on FPPopoverController.m is doing the following:

...
    NSArray *windows = [UIApplication sharedApplication].windows;

    if (windows.count > 0) {
        _parentView = nil;
        _window = [windows objectAtIndex:0];

        // keep the first subview.
        if (_window.subviews.count > 0) {
            _parentView = [_window.subviews objectAtIndex:0];
            [_parentView addSubview:self.view];
            [_viewController viewDidAppear:YES];
        }       
    } 
...

So, while retrieving the windows and subviews arrays, it is not checking if there are multiple elements, it only took the object at position 0:

_window = [windows objectAtIndex:0];

and

_parentView = [_window.subviews objectAtIndex:0];

That would fail to load the FPPopover on the visible view because as Apple documentation says:

@Property(nonatomic, readonly) NSArray *windows

Description
The application's visible and hidden windows. (read-only)
This property returns an array of the application's visible and hidden windows. The windows are ordered back to front.

and

@Property(nonatomic, readonly, copy) NSArray *subviews

Description
The receiver’s immediate subviews. (read-only)
You can use this property to retrieve the subviews associated with your custom view hierarchies. The order of the subviews in the array reflects their visible order on the screen, with the view at index 0 being the back-most view.

So, the windows array will not fail because the position 0 is the visible window, but in the case of the subviews array it is going to fail, or at least is not going to show anything to the user, because it is using the back-most subview, which is not currently being displayed. That would be fixed using the following code:

...
    NSArray *windows = [UIApplication sharedApplication].windows;

    if (windows.count > 0) {
        _parentView = nil;
        _window = [windows objectAtIndex:0];

        // keep the first subview.
        if (_window.subviews.count > 0) {
           _parentView = [_window.subviews objectAtIndex:(_window.subviews.count - 1)];
            [_parentView addSubview:self.view];
            [_viewController viewDidAppear:YES];
        }       
    } 
...

which the important code line is:

_parentView = [_window.subviews objectAtIndex:(_window.subviews.count - 1)];

That would retrieve the front-most subview and display correctly the FPPopover on the visible view.

Use UINavigationController in FPPopover

I am using code as below to show a Navigation controller in FPPopover, but the looks is very bad, what can I do?

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(UIBarButtonItem *)sender
    {
    if ([[segue identifier] isEqualToString:@"ShowList"]) {
    ListViewController *list = (ListViewController *)[segue destinationViewController];
    list.delegate = self;
    list.row = self.rowOfList;

    if (iPad) {
        UIPopoverController *popoverController = [(UIStoryboardPopoverSegue *)segue popoverController];
        self.iPadPopoverController = popoverController;
        popoverController.delegate = self;
    }
    else {
        UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:list];
        navbar.title = @"水滸108将大全";
        FPPopoverController *popoverController = [[FPPopoverController alloc] initWithViewController:navbar];
    
        self.iPhonePopoverController = popoverController;
        popoverController.delegate = self;
        popoverController.contentSize = CGSizeMake(300, 400);
        popoverController.tint = FPPopoverDefaultTint;
        popoverController.arrowDirection = FPPopoverArrowDirectionAny;
    
        UIView* btnView = [sender valueForKey:@"view"];
        [popoverController presentPopoverFromView:btnView];
    }
    

    }
    }
    iOS Simulator Screen shot 2013 02 11 2 41 24
    iOS Simulator Screen shot 2013 02 11 2 42 02

thin border

hi,
thx for your work. i like it :-)

how can i set the border to 1 or 2 pixels?

thx and regards
thorsten

ARC support

Please add support for automatic reference counting mode. ARC forbids explicit message send of 'release'.

The target view controller not added as child.

Subview is added to the FPPopoverController, but content view controller not added as child view controller. Consequence of this is lifecycle methods are not passed down to the content view (viewWillAppear, viewDidLoad, etc). Use [self addChildViewController:contentView] in FPPopoverController to fix it.

Popover is drawn with ContentSize smaller than specified

The contentSize.width becomes not a content controller width but whole popover (chrome) outer width.
contentSize.height appears to be subtracted by 40 -60 from contentSize passed to FPPopover.

Most evident if you create popover and specify:

popover.contentSize = CGSizeMake(100, 100);

Then measure what is on the screen (using XScope or similar). ContentSize will be 80x40! And popover size is 100x80.

Setting arrowDirection to FPPopoverArrowDirectionLeft, arrow is right-pointing

Hi!

When I set FPPopoverArrowDirectionRight, my popover appears in the right place. If I use FPPopoverArrowDirectionLeft, it appears in the same place as FPPopoverArrowDirectionRight. There's plenty of room around the origin point.

Sample project at http://borkware.com/hacks/Popupinator.zip - pretty much just has a button in the middle of an ipad, and a segmented control that lets you choose the arrow direction.

I narrowed it down to bestArrowDirectionAndFrameFromView, the test

    if(wl == best_w || self.arrowDirection == FPPopoverArrowDirectionRight)

Is matching the wl==best_w, ignoring the arrowDirection setting.

Here's a snapshot from the debugger:

debugger-session

if there's anything else I can supply, please let me know. [email protected]

Thanks!
++md

Close button in title bar- feature request

It would be great if we had a close button in the title bar and popup only closes when the users clicks on the close button. for data entry popups...if the user touches outside the popup may lose the data and has to reenter..

thanks

Issue with centering the popover to center of the view

I am having trouble with setting the popover view to the center of the view. Here's the code i am writing:

PBAlertsViewController *controller = [[PBAlertsViewController alloc] initWithNibName:@"PBAlertsViewController" bundle:nil];
controller.title=@"Alerts";

//our popover
FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller];

popover.contentSize=CGSizeMake(280, self.view.frame.size.height-44);

CGPoint location = CGPointMake(143, 20);

[popover presentPopoverFromPoint:location];

Resulting popover is not centered in view. See image below.. How can i set popover to align it to center of the view??

Screen Shot 2013-03-08 at 2 53 07 PM

Get rid of border?

Can we please have an option to have no border? I don't need to use the popover as a tableview. I just want to put a tint on it and use it to display some text, with no inside border at all

Crashes on iOS 6

Using the simple sample you provided, iOS apps crash as soon as the button is pressed and the
FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller];
function fires. It also does not work on iPad. Nothing shows in Xcode.

Table view return value

Hi,
Thanks for FPPopover you have saved our lives ;)
I just need help on how I can return the selected value from the Tableview when the method didSelectRowAtIndexPath is invoked to the main view controller.

Thanks

Option to remove arrow in popover.

Could you please add an option to FPPopoverArrowDirection to remove the arrow in the popover?

Considering that it is possible to remove the arrow from an iPad popover, would you mind adding this feature to FPPopover?

dealloc is not getting called - so orientation observers are not released

Hi,
When we set the popovercontroller to nil...dealloc should get called and orientation change observers should be removed...the dealloc is not being called and the popovercontroller holds in memory. and device orientation change method is called even though the popover is been destroyed..

thanks

1.4 breaks in project with arc

When used in project with ARC, FPPopover will crash the app when you dismiss it. Did you mean to remove the requires_arc pod setting?

Message sent to deallocated instance

I am currently using ARC in my project. I have run the target on iOS 6. Sometimes when I pop off a view controller that contains FPPopoverView, it crashes with the following error

[RecipeDetailViewController tableView:heightForRowAtIndexPath:]: message sent to deallocated

RecipeDetailViewController is the deallocated view controller that has been popped off. I think that the issue is due to the detailViewController being registered to the notification center and not being removed. The following is the stack for the thread causing crash.

stack

The following are the detailed stack.

  1. [FPPopoverController deviceOrientationDidChange:]

stack1

  1. [FPPopoverController setupView]
    stack2
  2. [FPPopoverController bestArrowDirectionAndFrameFromView]
    stack3
  3. [FPPopoverView setFrame:]
    stack4

Has anyone encountered this kind of issue while using it in ARC and IOS 6?

Please add this sample code to Readme.md

This code might be helpful.

- (IBAction)didTapBarButton:(UIBarButtonItem *)sender
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"xxxViewController"];
    FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:vc];
    UIView *view = [sender valueForKey:@"view"];
    [popover presentPopoverFromView:view];
}

Access to the table view for selecting rows etc.

I'd like to be able to select a row in the table view using my content view controller. I've tried selectRowAtIndexPath:animated:scrollPosition: without any luck. Is there any way I can select a row in the table view?

Doesn't properly release memory

If you run with instruments, memory allocs keep going up with each pop over displayed. They never go back down :(

Seems too hard for me to debug

Pressing a key outside the popovers frame, dismisses the control.

First, thank you for a very nice and easy to use control!

But have one problem.

I use the popover to display a fairly long list of options, and have a search/filter bar at the top.
When I enter the textfield the keyboard pops up as it should and everything works as it should, unless i touch a key that lies outside of the area that the popover covers.

In my case I can't switch to numeric keys or use the spacebar since it will instantly close the popover.

ContentSize with different orientations?

Hey,

I'm loving this popover implementation, so thank you!
I'm having a slight issue though although I may just be being stupid.

I'm trying to set the content size so that the tableview I have inside doesn't show any blank rows under the populated rows. I've got this working and it's great, but when I rotate the device, it resizes the popover so it then becomes too small. I'm using the following to display the popover

MPOptionsSelectionViewController *options = [[MPOptionsSelectionViewController alloc] initWithStyle:UITableViewStylePlain selectionType:MPOptionsSelectionList];
options.options = _sortOptions;
options.delegate = self;
_popover = [[FPPopoverController alloc] initWithViewController:options];
_popover.contentSize = CGSizeMake(160, 175);

UIBarButtonItem *btn = (UIBarButtonItem *)sender;
[_popover presentPopoverFromView:[btn valueForKey:@"view"]];

In portrait, this looks great, but when rotated to landscape the height is reduced and only 2 of my 3 rows become visible. Is there any nice way around this, or do I have to manually change the content size in response to the devices rotation?

Thanks

If crate new VC and init , and release , so it's crash. Please check out.

//the view controller you want to present as popover
YourViewController *controller = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil]; 

//our popover
FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller]; 

//the popover will be presented from the okButton view 
[popover presentPopoverFromView:okButton]; 


[controller release];//RELEASE

/**
I haven't use ARC , so RELEASE is crash .

*/

//Terminer error message
An instance 0x6840420 of class YourViewController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x684ac80> (
<NSKeyValueObservance 0x684aac0: Observer: 0x683a820, Key path: title, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x684a0c0>
)

Delegate Issues

I'm having some issues (running Xcode 5, iOS7) with assigning a delegate. I'm looking at the tutorial code,

Assigning to 'id' from incompatible type 'saveLoadScifi *'

where saveLoadScifi is my controller

Anyone got any idea why this would be? Having a delegate is somewhat vital to my app :-/

FPPopover for Cocoapods

Hi guys -

I would really love to use FPPopover in my Rubymotion project.

Would you mind creating a cocoa pod for it? The instructions are on the cocoapods homepage - it's just a 5 minute job

Thanks

Remote Notification app issue with FPPopover

Hello,
I am using FPPopover in my project and i was successful in displaying the popup in one of my view controller uibutton.
I am using remote notification as well in my app. when i open the app through notification which i recieved and try to click the uibutton for popup, i was not able to get the popup. Can you please help me out?

XCode 5.0 / iOS 7?

For some reason I can't get the view view I allocate and init to use as the popover's view to show at all in this call:

self.addContentMenuViewController = [[HSZ_AddContentMenuViewController alloc] init];
self.popover = [[FPPopoverController alloc] initWithViewController:self.addContentMenuViewController];

I tried changing HSZ_AddContentMenuViewController to and empty view and changing the background color, but all I get is a white rounded rectangle.

Has FPPopoverController been verified in the new XCode and iOS?

popup from uibarbuttonitem

Hi,

Is it possible to popoverfrom uibarbuttonitem?

and also presentPopoverfrompoint is always presents the popup at 0,0....

any suggestion how to fix it?

about arc

Origin

//ARC-enable and disable support

if __has_feature(objc_arc)

@property(nonatomic,assign) id<FPPopoverControllerDelegate> delegate;

else

@property(nonatomic,assign) id<FPPopoverControllerDelegate> delegate;

endif

I believe should be this:

//ARC-enable and disable support

if __has_feature(objc_arc)

@property(nonatomic,weak) id<FPPopoverControllerDelegate> delegate;

else

@property(nonatomic,assign) id<FPPopoverControllerDelegate> delegate;

endif

Calling presentPopoverFromPoint following a call to presentPopoverFromView doesn't work

This appears to be because the _fromView instance variable gets set when presentPopoverFromView is called and never gets cleared.

To work around it in my project, I added the following method to FPPopoverController:

- (void) resetView
{
    SAFE_ARC_RELEASE(_fromView);
    _fromView = nil; 
}

I call this method when I need to move the popover and it appears to work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.