nicolaschengdev / wypopovercontroller Goto Github PK
View Code? Open in Web Editor NEWWYPopoverController is for the presentation of content in popover on iPhone / iPad devices. Very customizable.
License: Other
WYPopoverController is for the presentation of content in popover on iPhone / iPad devices. Very customizable.
License: Other
See DemoSegue app,
file WYPlayersViewController.m
at line 51 :
popoverController = [popoverSegue popoverControllerWithSender:sender permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
The popover is not animated when it appears even if animated argument is passed to YES.
Is it possible to use UIImagePickerController with WYPopoverController on iPad?
When I tried to do so, I received the following error:
On iPad, UIImagePickerController must be presented via UIPopoverController
Should you be setting
self.layer.delegate = nil;
in the dealloc method for WYPopoverBackgroundView? I am having some odd crashes that I cannot reproduce (live apps) and I think I have possibly traced the error back here.
modalInPopover
A Boolean value indicating whether the view controller should be presented modally by a popover.
@property(nonatomic, readwrite, getter=isModalInPopover) BOOL modalInPopover
Discussion
The default value of this property is NO. Setting it to YES causes an owning popover controller to disallow interactions outside this view controller while it is displayed. You can use this behavior to ensure that the popover is not dismissed by taps outside the popover controller.
Availability
Available in iOS 3.2 and later.
Declared In
UIPopoverController.h
The popover does not showing well on iOS7.
It's totally shrinked.
Thanks in advance.
If i tried to show the popover while UICollectionView is scrolling it does not appear until the collectionView stops scrolling (I did not test it with UITableView or other scrollViews)
Thanks for a great control. Changes to UIAppearance do unfortunately not apply to existing instances of a control. Thus it is currently not possible to change the colors of a popover while it is shown.
It seems there's some extra space between the bottom border and the contentView
with iOS7. The same code works nicely on iOS6.
preferredContentSize is used with iOS7 and contentSizeForViewInPopover on iOS6
I'm having the same issues with WYPopoverController in iOS7
where it becomes slower and slower described here:
http://stackoverflow.com/questions/19144139/cache-eraseimp-nolock-taking-very-long-in-ios-7
Maybe its a good thing to gradually deprecate the use of UIAppearance?
its crashing on ios 6
2013-09-18 10:45:55.021 WYPopoverDemo[4607:c07] -[WYSettingsViewController setPreferredContentSize:]: unrecognized selector sent to instance 0x75c68c0
2013-09-18 10:45:55.027 WYPopoverDemo[4607:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WYSettingsViewController setPreferredContentSize:]: unrecognized selector sent to instance 0x75c68c0'
*** First throw call stack:
When attempting to add a UINavigationController to the popover it will appear, however any push of a viewController ( [self performSegueWithIdentifier:@"segueName" sender:self]) will fail to do anything.
Any ideas?
Cheers
I appreciate your prompt support. Great for overtime.
I have just upgrade to 0.1.2 for issue #15. Now the following exception is occurring.
-[CALayer setDrawsAsynchronously:]: unrecognized selector sent to instance 0xa416480
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer setDrawsAsynchronously:]: unrecognized selector sent to instance 0xa416480'
self.layer.drawsAsynchronously = YES;
iOS 6 only now?
Cheers
Hi,
Great library. I'm using this in my second project. In this one however, I have run in to a small situation. The popover I'm displaying is fairly long. Therefore when the keyboard comes up, it overlaps the popover.
As a solution, I added a UIScrollView to the popover and in viewDidLayoutSubviews mthod, I set its its contentSize and frame. Like so
self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, self.scrollView.frame.size.height);
self.scrollView.frame = self.view.frame;
This almost works. The scrollview works as expected but there's a small hitch. The scrollview doesn't cover the entire popover screen.
Notice the first textfield disappearing from the middle of the screen.
I have a demo project here if this is all too confusing.
https://www.dropbox.com/s/gfcp5q364z4k968/PopoverTest.zip
Can you please take a look at it and tell me how to correct this? I'd really appreciate it.
Thank you.
Whenever I needed a custom modal popup dialog, I would always customize UIAlertView. This leads to trouble since it is not supported and Apple always changes the innerworkings of UIAlertView causing my customizations to break with every iOS release. Therefore, I started looking at thirdparty popover controllers (to gain iPhone support) and found this one. It looks and works great. However, when I want to present it, I must specify some barbutton or view rect to anchor it to. In order to use this popover controller as more of a general purpose custom dialog popup, it would be nice if there was a new WYPopoverArrowDirection.None and the ability to show it without referencing some anchor point. The None arrow direction would mean do not show an arrow AND center the dialog on the screen. I can achieve the hidden arrow by setting the arrowHeight = 0, but I can't find an easy way to just center the popover on the screen. Could this enhancement be added? It sounds easy.
Crashes on this line:
arrowDirection = ((WYPopoverArea*)[areas objectAtIndex:0]).arrowDirection;
This happens for me when I set the popoverContentSize
Also, ideally the ([areas count] > 1) check should be extended.
The methods
NSString* NSStringFromOrientation(NSInteger orientation)
and
CGFloat GetStatusBarHeight()
generate a warning "No previous prototype for function" because the 'static' keyword is missing.
To fix these warnings, the static keyword needs to be added:
static NSString* NSStringFromOrientation(NSInteger orientation)
static CGFloat GetStatusBarHeight()
Hi,
I'm getting the following Xcode 5 analyser warning…
/snip/Classes/WYPopoverController/WYPopoverController.m:951:17: Value stored to 'reducedOuterCornerRadius' during its initialization is never read
Jules.
This doesn't seem to work for me.
CCRootViewController *ccrvc = [[CCRootViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:ccrvc];
self.popoverController = [[WYPopoverController alloc] initWithContentViewController:navController];
self.popoverController.delegate = self;
[self.popoverController presentPopoverFromRect:self.bounds inView:self permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
Performing a pod update generates the following error.
[!] The platform of the target Pods
(iOS 5.1) is not compatible with WYPopoverController (0.1.4)
which has a minimum requirement of iOS 6.0.
If the keyboard is shown or hidden then popover should adjust this layout.
@nicolaschengdev, the last commit removed the Podspec, making it impossible to do
pod 'WYPopoverController', :git => 'https://github.com/nicolaschengdev/WYPopoverController'
Hello guys,
I stumbled upon this component 2 days ago and it would fit my requirements perfectly, but I am not getting it running in my scenario.
I built a very simple test case:
What am I doing wrong? Is there a bug or did I forget some configuration? Could anyone help me out on this one? I would really like to use this component.
Thanks in advance,
SlimShady0208
Thanks for a great control!
It seems to me there is a small issue in
- (UIView *)rootView
{
UIWindow *result = [[UIApplication sharedApplication] keyWindow];
if (result.subviews.count > 0)
{
result = [result.subviews lastObject];
}
return result;
}
It's not good idea to select blindly last view from a window as an parent. At least it should be checked for visibility etc. But I think to move rootView property to the public interface is a better approach: if a user does not set this property then select something from window's subviews.
Thanks!
Hi,
I've started to use WYPopover in my project a few months ago. Everything works fine until I try to put my view controller in a navigation controller.
I need to push another view controller, but I don't need navigation bar in first view controller.
So I set 'top bar' property of the navigation controller to none. However, there is something wrong with the navigation bar.
Here I use the demo project 'DemoSegue' as an example.
Normal
It can be seen that there is a weird gray line above the bottom part of 'Player Name'.
Since the background is white, so the problem is not obvious. I changed the background color to make it more obvious.
Is this a bug, or I was using it in a wrong way?
The duration is too short, so it looks like flash when it shows up.
Hope I can control it.
Thank you.
I am using this code just like the one in the Demo:
- (IBAction)showpopover:(id)sender
{
if (settingsPopoverController == nil)
{
UIView* btn = (UIView*)sender;
WYSettingsViewController *settingsViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WYSettingsViewController"];
if ([settingsViewController respondsToSelector:@selector(setPreferredContentSize:)]) {
settingsViewController.preferredContentSize = CGSizeMake(280, 200); // iOS 7
}
else {
settingsViewController.contentSizeForViewInPopover = CGSizeMake(280, 200); // iOS < 7
}
settingsViewController.title = @"Settings";
[settingsViewController.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)]];
settingsViewController.modalInPopover = NO;
UINavigationController* contentViewController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
settingsPopoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
settingsPopoverController.delegate = self;
settingsPopoverController.passthroughViews = @[btn];
settingsPopoverController.popoverLayoutMargins = UIEdgeInsetsMake(10, 10, 10, 10);
settingsPopoverController.wantsDefaultContentAppearance = NO;
[settingsPopoverController presentPopoverFromRect:btn.bounds
inView:btn
permittedArrowDirections:WYPopoverArrowDirectionAny
animated:YES
options:WYPopoverAnimationOptionFadeWithScale];
}
else
{
[self done:nil];
NSLog(@"test");
}
}
#pragma mark - Selectors
- (void)done:(id)sender
{
[settingsPopoverController dismissPopoverAnimated:YES];
settingsPopoverController.delegate = nil;
settingsPopoverController = nil;
}
#pragma mark - WYPopoverControllerDelegate
- (BOOL)popoverControllerShouldDismissPopover:(WYPopoverController *)controller
{
return YES;
}
- (void)popoverControllerDidDismissPopover:(WYPopoverController *)controller
{
if (controller == settingsPopoverController)
{
settingsPopoverController.delegate = nil;
settingsPopoverController = nil;
}
}
Notice that I have placed a NSLog(@"test"); under the self done, your demo has not gone and displayed that line in the log (expected behaviour). However, mine does when user did not use the Done button to close the Popover. What other codes am I missing? How can I rectify this?
I have the following code.
UINavigationController navigationController = [[UINavigationController alloc] initWithRootViewController: [self.storyboard instantiateViewControllerWithIdentifier:name]];
UIViewController *contentViewController = navigationController;
WYPopoverController popoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
popoverController.delegate = self;
[popoverController presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
The controller loaded via the storyboard called is a UITableViewController. The UITableViewController is loaded, however any future calls to push additional view controllers within this wrapped controller results in the following error.
Exception - Could not find a navigation controller for segue 'selectCategory'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.
It is like the controller within the popover has dropped the UINavigationController.
Tells the delegate that the popover controller needs to change the popover’s location in its view.
- (void)popoverController:(UIPopoverController *)popoverController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView **)view
popoverController
The popover controller changing the position of its content.
rect
On input, the proposed rectangle for the popover. This popover is in the coordinate space of the view in the view parameter. If you want to propose a different rectangle for the popover, put the new value in this parameter.
view
On input, the proposed view for containing the popover. If you want to propose a different view for the popover, put the new view in this parameter.
For popovers that were presented using the presentPopoverFromRect:inView:permittedArrowDirections:animated:
method, the popover controller calls this method when the interface orientation changes. Your delegate can use this method to adjust the proposed position of the popover. The popover controller does not call this method if you presented the popover from a bar button item.
Available in iOS 7.0 and later.
UIPopoverController.h
The WYPopoverController has graphical glichtes in iOS7. Is it planned to Support iOS7 as well?
Thanks for your Help!
WYPopoverController does not conform to UIAppearanceContainer. I'm using pod 'WYPopoverController', '~> 0.1.7' on 7.1 (b3).
Calling something like the following causes crash:
UINavigationBar* navBarInPopoverAppearance = [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], [WYPopoverController class], nil];
Fix:
Add protocol to class header: @interface WYPopoverController : NSObject
For WYPopoverController.m, I think it is better to change the codes in the if statements from line 1395 to the following:
[UIView animateWithDuration:0.15 animations:^{
overlayView.alpha = 0;
} completion:^(BOOL finished) {
completionBlock(YES);
[viewController viewWillDisappear:YES];
}];
Hi Nicolas,
I have run into another problem. I want to display the popover when the UITableViewCell's accessoryView is tapped on. I have all the code and the views set up right. I checked by displaying it from a UIBarButtonItem. Even from a UITableViewCell, it displays the popover but not when you tap on the accessoryView.
Can you please tell me how I can do this?
I have a runnable Xcode project here.
https://www.dropbox.com/s/g10cu5unmswdn72/PopoverfromtableviewTest.zip
Many thanks as always.
My app is a storyboard app and I'm presenting it using WYStoryboardPopoverSegue (like in the DemoSegue project in the example projects). The view controller is embedded in a UINavigationBarController so a a navigation bar appears in the popover view as intended.
Somehow that navigation bar wouldn't conform to the UAppearence proxy I had set up in the app's AppDelegate file. Therefore I changed its background color from in the popover's viewDidLoad method and it works. But the arrow still appears in default color.
How can I change the arrow's color as well?
I tried making an instance of WYPopoverBackgroundView to set its values and see but I don't know where I should assign the WYPopoverBackgroundView's instance to the popover.
Thank you
I remove observers on the viewWillDisappear. When tapping outside the popup or on the done button the viewWillDisappear is triggered twice. In my case the app. crashes due to the observer is already removed.
Reproduce. add WYSettingsViewController to view the message being called twice.
Setting the borderWidth property to 0 results in a visual glitch at the bottom of the popover.
[[WYPopoverBackgroundView appearance] setBorderWidth:0]
Ideally if outerCornerRadius > 0 and borderWidth == 0, the outerCornerRadius is used in the bottom of the popover so that a rounded corner is possible.
I found problem when i change the appearance color to black the title is black color too, how to change title color to other color. Help me to hide the blue Done button. Can I expand the area in the botton of WYPpover? and add other button in there place
here is image from simulator and some code
http://postimg.org/image/9qpr6cand/
Hi,
The master works pretty fine on iOS 7 👍
But there are still warnings popped out suggesting using UIViewController.preferredContentSize
instead. I am thinking of a possible workaround which will check if the view controller respond to preferredContentSize
first. If not, then fallback to use contentSizeForViewInPopover
.
Anyone pops an IASKAppSettingsViewController
InAppSettingsKit inside WYPopoverController
successfully? I following the UINavigationController
sample:
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:self.infoViewController];
UIViewController* contentViewController = navigationController;
WYPopoverController* popoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.infoButton.bounds
inView:self.infoButton
permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
but second-level IASKAppSettingsViewController
s are not pushed as expected.
Hi. I was trying to customize the popover appearance but it seems that the proxies are implemented in an internal view not exposed with public API. I'm missing something?
regards,
MB
Hi,
Thank you for your great work, I really like it!
One issue: If I show the popover I can add an option how it should be animated, unfortunately this is not possible if I dismiss the popover.
Bests,
Philip
Probably it will be great not only check for if(!view.isHidden) because when I use hud it's the first element :) Maybe it will be better to check for [view isKindOfClass:UIViewController] ?
(UIView *)rootView
{
UIWindow *result = [[UIApplication sharedApplication] keyWindow];
if (result.subviews.count > 0)
{
for (UIView *view in result.subviews)
{
if(!view.isHidden)
{
return view;
}
}
// result = [result.subviews lastObject];
}
return result;
}
After I integrated chartboost's Ad, the popover view can not be shown up.
It seems that now we cannot use WYPopoverControl on iOS 6 via CocoaPods, because of this line:
s.ios.deployment_target = '7.0'
Is it mistake?
Why was ios5.1 chosen instead of ios5.0 in the podspec?
on the other hand i get this,
[!] The platform of the target Pods
(iOS 5.1) is not compatible with WYPopoverController (0.1.7)
which has a minimum requirement of iOS 6.0.
but the podspec specifies 5.1 as deployment target
There are numerous places in the WYPopoverController code where 'self' is being implicitly retained.
Enable the compiler warning: "Implicit retain of 'self' within blocks" (CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF, -Wimplicit-retain-self) and you'll see them.
Popover is not animated when changing popoverContentSize
property.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.