iPadNewProperty (2015-11-18 星期三)

#import "AppDelegate.h"
#import "ViewController.h"


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    ViewController *rootVC = [[ViewController alloc] init];
    UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:rootVC];
    self.window.rootViewController = naVC;
    return YES;
}
#import "ViewController.h"
@interface ViewController ()<UIPopoverControllerDelegate>
@property(nonatomic, strong)UIPopoverController *popOver;
@end


@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor orangeColor];

    UIViewController *contentVC = [[UIViewController alloc] init];

    //  初始化方法
    self.popOver = [[UIPopoverController alloc] initWithContentViewController:contentVC];
    self.popOver.popoverContentSize = CGSizeMake(300, 600);
    self.popOver.delegate = self;

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(BarButtonAction:)];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor purpleColor];
    button.frame = CGRectMake(100, 100, 100, 50);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];

    UIButton *Abutton = [UIButton buttonWithType:UIButtonTypeSystem];
    Abutton.backgroundColor = [UIColor purpleColor];
    Abutton.frame = CGRectMake(300, 100, 100, 50);
    [self.view addSubview:Abutton];
    [Abutton addTarget:self action:@selector(AbuttonAction:) forControlEvents:UIControlEventTouchUpInside];

    //  点击数组内的视图, 弹出窗口不会消失
    self.popOver.passthroughViews = @[Abutton];

}

- (void)AbuttonAction:(UIButton *)button {

}

#pragma mark    - popOverDelegate
//  发生改变的时候
- (void)popoverController:(UIPopoverController *)popoverController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView *__autoreleasing   *)view {
    NSLog(@"变形");
}
//  消失
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
    NSLog(@"消失");
}
//  点击空白消失, 默认为YES
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
    NSLog(@"~消失");
    return YES;
}

- (void)buttonAction:(UIButton *)button {

    //  第二种显示方法
    [self.popOver presentPopoverFromRect:button.bounds inView:button permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}

- (void)BarButtonAction:(UIBarButtonItem *)button {

    //  第一种显示方法
    [self.popOver presentPopoverFromBarButtonItem:button permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
...
@end
阅读更多
文章标签: iPad的几个属性
上一篇Git
下一篇零碎知识点
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭