Friday 22 August 2014

iPhone PopOverController - Sample Code for iPhone

Download or copy the Two Files. Added code into your project.





.m File:
#import "WYPopoverController.h"

@interface ViewController ()<WYPopoverControllerDelegate>
{
    WYPopoverController *settingsPopoverController;
}

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
}

-(IBAction) info_Action:(id) sender
{
    UIButton *btn = (UIButton *) sender;
if (settingsPopoverController == nil)
   {
        settingsPopoverController = [[WYPopoverController alloc] initWithContentViewController:product_info]; //View Controller Name : product_info
    settingsPopoverController.delegate = self;
settingsPopoverController.popoverContentSize = CGSizeMake(291, 205); //Size for Pop Over
    settingsPopoverController.passthroughViews = @[btn];
    settingsPopoverController.popoverLayoutMargins = UIEdgeInsetsMake(10, 10, 10, 10);
    settingsPopoverController.wantsDefaultContentAppearance = NO;
    [settingsPopoverController beginThemeUpdates];
    settingsPopoverController.theme.arrowHeight = 7;
    settingsPopoverController.theme.arrowBase = 15;
    [settingsPopoverController endThemeUpdates];
    [settingsPopoverController presentPopoverFromRect:btn.bounds
                                               inView:btn
                             permittedArrowDirections:WYPopoverArrowDirectionAny
                                             animated:YES
                                              options:WYPopoverAnimationOptionFadeWithScale];
}
else
{
         [settingsPopoverController dismissPopoverAnimated:YES];
        settingsPopoverController.delegate = nil;
         settingsPopoverController = nil;
}
}

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

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

No comments: