Code Monkey home page Code Monkey logo

wypopovercontroller's Introduction

WYPopoverController

WYPopoverController is for the presentation of content in popover on iPhone / iPad devices. Very customizable.

Screenshots


Features


  • UIAppearance support
  • Works like UIPopoverController
  • Works also with blocks
  • Animation options
  • Automatic orientation support
  • UIStoryboard support
  • Keyboard show / hide support
  • iOS 6 & 7 support
  • UIAccessibility support
  • Theme support

UIAppearance support


Property Type Default value (iOS 6) Default value (iOS 7)
tintColor UIColor nil nil
arrowBase NSUInteger 42 25
arrowHeight NSUInteger 18 13
borderWidth NSUInteger 6 0
outerCornerRadius NSUInteger 8 5
innerCornerRadius NSUInteger 6 0
viewContentInsets UIEdgeInsets { 3, 0, 0, 0 } UIEdgeInsetsZero
fillTopColor UIColor #373f47ff #f4f4f4ff
fillBottomColor UIColor #3b434cff #f4f4f4ff
glossShadowColor UIColor #c3c5c77f #transparent
glossShadowBlurRadius NSUInteger 0 0
glossShadowOffset CGSize { 0, 1.5 } CGSizeZero
outerShadowColor UIColor #000000bf #transparent
outerShadowBlurRadius NSUInteger 8 0
outerShadowOffset CGSize { 0, 2 } CGSizeZero
innerShadowColor UIColor #000000bf #transparent
innerShadowBlurRadius NSUInteger 2 0
innerShadowOffset CGSize { 0, 1 } CGSizeZero
minOuterCornerRadius NSUInteger 0 0
innerStrokeColor UIColor #262c31ff #transparent
outerStrokeColor UIColor #262c31ff #transparent
Arrow & Border

, ,

Corner radius & View content insets

, ,

Stroke & Fill

, , ,

Gloss

, ,

Outer

, ,

Inner

, ,

Works like UIPopoverController


passthroughViews

An array of views that the user can interact with while the popover is visible.

wantsDefaultContentAppearance

Determines whether the default content appearance should be used for the popover.

popoverLayoutMargins

The margins that define the portion of the screen in which it is permissible to display the popover.

Works also with blocks


A block object can be executed when animation sequences ends. This parameter may be nil.

Important : If a block object is defined then correspondent delegate methods is not called.

Example

popover = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
[popover presentPopoverAsDialogAnimated:YES
                             completion:^{
                                 // Code executed after popover presentation animation sequence ends
                             }];

Animation options


There are 3 styles of animation :

  • Fade (by default)
  • Scale
  • Fade with Scale

Example

popover = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
[popover presentPopoverFromRect:btn.bounds
                         inView:btn
       permittedArrowDirections:WYPopoverArrowDirectionAny
                       animated:YES
                        options:WYPopoverAnimationOptionFadeWithScale];

ARC


WYPopoverController uses ARC.

Installation


iOS SDK 7.0 (with Xcode 5) is required.

Cocoapods

Add this line pod 'WYPopoverController', '~> 0.2.0' to your PodFile.

Your PodFile should look like :

platform :ios, '6.0'
pod 'WYPopoverController', '~> 0.2.2'

To use the master branch of the repo :

platform :ios, '6.0'
pod 'WYPopoverController', :git => 'https://github.com/nicolaschengdev/WYPopoverController.git'

Manually

Add these files to your project :

  • WYPopoverController.h and WYPopoverController.m
  • WYStoryboardPopoverSegue.h and WYStoryboardPopoverSegue.m

And link QuartzCore.framework library in the Build Phases of your project targets.

Examples


Simple

In the implementation of your view controller

// YourViewController.m

@interface YourViewController () <WYPopoverControllerDelegate>
{
    WYPopoverController* popoverController;
}

- (IBAction)showPopover:(id)sender;

@end

@implementation YourViewController

- (IBAction)showPopover:(id)sender
{
	popoverController = [[WYPopoverController alloc] initWithContentViewController:controller];
    popoverController.delegate = self;
    [popoverController presentPopoverFromRect:button.bounds inView:button permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
}

- (BOOL)popoverControllerShouldDismissPopover:(WYPopoverController *)controller
{
    return YES;
}

- (void)popoverControllerDidDismissPopover:(WYPopoverController *)controller
{
    popoverController.delegate = nil;
    popoverController = nil;
}

@end
Appearance (Tint Color)
[WYPopoverController setDefaultTheme:[WYPopoverTheme theme]];

WYPopoverBackgroundView *appearance = [WYPopoverBackgroundView appearance];
[appearance setTintColor:[UIColor orangeColor]];
Appearance (Flat Popover)
UIColor *greenColor = [UIColor colorWithRed:26.f/255.f green:188.f/255.f blue:156.f/255.f alpha:1];

[WYPopoverController setDefaultTheme:[WYPopoverTheme theme]];

WYPopoverBackgroundView *popoverAppearance = [WYPopoverBackgroundView appearance];
        
[popoverAppearance setOuterCornerRadius:4];
[popoverAppearance setOuterShadowBlurRadius:0];
[popoverAppearance setOuterShadowColor:[UIColor clearColor]];
[popoverAppearance setOuterShadowOffset:CGSizeMake(0, 0)];
        
[popoverAppearance setGlossShadowColor:[UIColor clearColor]];
[popoverAppearance setGlossShadowOffset:CGSizeMake(0, 0)];
        
[popoverAppearance setBorderWidth:8];
[popoverAppearance setArrowHeight:10];
[popoverAppearance setArrowBase:20];
        
[popoverAppearance setInnerCornerRadius:4];
[popoverAppearance setInnerShadowBlurRadius:0];
[popoverAppearance setInnerShadowColor:[UIColor clearColor]];
[popoverAppearance setInnerShadowOffset:CGSizeMake(0, 0)];
        
[popoverAppearance setFillTopColor:greenColor];
[popoverAppearance setFillBottomColor:greenColor];
[popoverAppearance setOuterStrokeColor:greenColor];
[popoverAppearance setInnerStrokeColor:greenColor];
        
UINavigationBar* navBarInPopoverAppearance = [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], [WYPopoverController class], nil];
[navBarInPopoverAppearance setTitleTextAttributes: @{
                  UITextAttributeTextColor : [UIColor whiteColor],
            UITextAttributeTextShadowColor : [UIColor clearColor],
           UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0, -1)]}];
Storyboard
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
	if ([segue.identifier isEqualToString:@"[YOUR_SEGUE_IDENTIFIER]"])
	{
		WYStoryboardPopoverSegue* popoverSegue = (WYStoryboardPopoverSegue*)segue;

		UIViewController* destinationViewController = (UIViewController *)segue.destinationViewController;
        destinationViewController.contentSizeForViewInPopover = CGSizeMake(280, 280);		// Deprecated in iOS7. Use 'preferredContentSize' instead.

        popoverController = [popoverSegue popoverControllerWithSender:sender permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
        popoverController.delegate = self;
	}
}
Theme

Introduced in 0.2.1 release, you can change appearance of your popovers with themes.

- (void)changePopoverTheme
{
    popover.theme = [WYPopoverTheme themeForIOS6];  // you set a new theme

    // use beginThemeUpdates and endThemeUpdates methods if you have to change several values which compose your current theme
    
    [popover beginThemeUpdates];
        popover.theme.arrowHeight = 30;
        popover.theme.arrowBase = 40;
    [popover endThemeUpdates];
}
Keyboard

By default, when keyboard is shown, popover will be repositionned if it is (partially) hidden. Introduced in 0.2.1 release, you can control value of y offset when keyboard is shown with the following delegate method :

- (void)popoverController:(WYPopoverController *)popoverController willTranslatePopoverWithYOffset:(CGFloat *)value
{
    *value = 0; // if value is setted to 0 then popover will not be translated
}

Handling popover controllers during orientation changes


When showing a popover controller, there are times when you will need to handle how the popover controller appears after a change in device orientation.

Situations when handling is required:

  • If the popover controller is presented from a target rectangle using the -presentPopoverFromRect:inView:permittedArrowDirections:animated method of WYPopoverController. You can use -popoverController:willRepositionPopoverToRect:inView: method introduced in the 0.1.6 release .
  • If the popover controller is presented from a bar button item that is removed after the rotation has finished .

Change logs


A brief summary of each WYPopoverController release can be found on the wiki.

Contact


License


WYPopoverController is available under the MIT license.

Copyright © 2013 Nicolas CHENG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

wypopovercontroller's People

Contributors

cbess avatar fdddf avatar gerasim13 avatar hsoi avatar igrandav avatar jhersh avatar ksjun avatar nicolaschengdev avatar scastria avatar shkutkov avatar tspacek 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wypopovercontroller's Issues

Add animation Option to dismiss

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

WYPopoverController does not conform to UIAppearanceContainer

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

Work with InAppSettingsKit?

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 IASKAppSettingsViewControllers are not pushed as expected.

Popover never fadeout

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];
}];

implicit retain of 'self' within blocks

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.

Supporting UINavigationController

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

rootView some times problem in this place of logic.

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;
    }

Visual glitch when borderWidth property set to 0

Setting the borderWidth property to 0 results in a visual glitch at the bottom of the popover.
wypopover

[[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.

Using UIAppearance prevents dynamic changes

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.

Navigation bar appearance weird when it is hidden.

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
normal

Hide Navigation Bar
abnormal

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.

abnormal-1

Is this a bug, or I was using it in a wrong way?

ios5.0

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

UIImagePickerController on iPad

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

'contentSizeForViewInPopover' is deprecated in iOS 7

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.

ios6 issue

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:

Minimum requirement of iOS 7.0

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?

NSStringFromOrientation and GetStatusBarHeight should be marked as static

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()

Has iOS5 support been removed from the pod?

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.

No Podspec

@nicolaschengdev, the last commit removed the Podspec, making it impossible to do
pod 'WYPopoverController', :git => 'https://github.com/nicolaschengdev/WYPopoverController'

Usage as custom dialog popup?

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.

Add '-popoverController:willRepositionPopoverToRect:inView:' support on delegate

-popoverController:willRepositionPopoverToRect:inView:

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
Parameters

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.

Discussion

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.

Availability

Available in iOS 7.0 and later.

Declared In

UIPopoverController.h

iOS7 support

The popover does not showing well on iOS7.

It's totally shrinked.

Thanks in advance.

viewWillDisappear is being called twice.

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.

  • (void) viewWillDisappear:(BOOL)animated {
    NSLog(@"viewWillDisappear");
    }

Using a storyboard identifier - drops UINavigationController

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.

Using UINavigationController as ContentViewController

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];

Showing the popover from the accessoryView in UITableViewCell

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.

WYPopoverController crashes if areas array is empty

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.

iOS7 Support?

The WYPopoverController has graphical glichtes in iOS7. Is it planned to Support iOS7 as well?

Thanks for your Help!

When the keyboard over laps the popover

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.
screen shot 2014-02-02 at 8 30 33 pm
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.

Add property 'modalInPopover' support

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

selecting a parent view(rootView)

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!

Appereance proxy

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

Nothing shown when user click outside the window without using the Done button to close

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?

WYPopoverController is shown 'behind' a UIViewController that is presented modal with 'UIModalPresentationPageSheet'

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:

  • I have a button im my main view, that opens up an UIViewController with 'UIModalPresentationPageSheet' presentation style.
  • Inside this modal view Controller there is another button, which should open up the WYPopoverController.
  • When I touch that button, the WYPopoverController is shown 'behind' the modal view controller.

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

Arrow doesn't get the Navigation bar's background color

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.

screen shot 2014-02-04 at 10 44 13 am

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

iOS7 content size

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

Is iOS 5.1 supported - setDrawsAsynchronously?

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

Popover coming from a segue is not animated

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.

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.