ipad控件之UIPopoverController(只在ipad中使用)


用於顯示臨時內容,特點是總是顯示在當前視圖最前端,當單擊界面的其他地方時自動消失。

 

彈出框其實可以設定為另一個界面了:

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM