用于显示临时内容,特点是总是显示在当前视图最前端,当单击界面的其他地方时自动消失。

 

弹出框其实可以设定为另一个界面了:

eg:点击按钮触发clickButton事件:

- (void)clickIButton:(id)sender
{
    //进入关于界面
    WBAbourtViewController *abourtViewController = [[WBAbourtViewController alloc] initWithNibName:@"WBAbourtViewController" bundle:nil];
    abourtViewController.title = @"关于我们";
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:abourtViewController];
    UIPopoverController* abourtPopoverController = [[UIPopoverController alloc] initWithContentViewController:navigation];

    abourtPopoverController.popoverContentSize = CGSizeMake(320,480);
    CGRect rect = CGRectMake(983,700+25,15,15);
    
    //弹出关于界面
    [abourtPopoverController presentPopoverFromRect:rect         //中心点是用来画箭头的,如果中心点如果出了屏幕,系统会优化到窗口边缘
                                              inView:self.view      
                            permittedArrowDirections:UIPopoverArrowDirectionDown   //箭头方向
                                            animated:YES];
    
    
}

WBAbourtViewController即为另建的一个类,在其.m代码实现另一个界面
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    NSURL *imageUrl = [NSURL URLWithString:[[NSUserDefaults standardUserDefaults] objectForKey:@"ABOUTUS"]];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
    [imageView setImageWithURL:imageUrl];
    [self.view addSubview:imageView];
    [imageView release];


//增加一下语句设定给界面大小
[
self setContentSizeForViewInPopover:CGSizeMake(320, 440)];

}

//即为WBAbourtViewController.m中的实现代码,显示url图片

 

 也可以实现列表格式,就如下图的所示样子:

 

 

 

官方文档: UIPopoverController Class Reference

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html

UIPopoverController+UINavigationController的使用http://1058813598.diandian.com/post/2012-05-18/19055936

版权声明:本文为ios-wmm原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ios-wmm/archive/2012/09/03/2668885.html