2011-12-29 30 views
0

我在項目的屏幕右下角添加了一個信息按鈕。按下此按鈕時顯示的常見視圖是什麼?我基本上希望顯示一般的應用程序和開發人員信息,但我也希望能夠在將來添加一個或兩個按鈕,以將用戶帶到我的應用商店頁面等。 UIAlertView並不完全符合我的想法。我想象出一種灰色的半透明盒子突然出現在主視圖上。什麼是iPhone信息按鈕顯示的典型視圖?

我的項目目前只有一個視圖控制器。我的應用程序基本上接收視頻並對其進行處理,因此我從不離開該主視圖。這是我如何添加按鈕:

- (void)viewDidLoad 
{ 
    infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark]; 
    [infoButton addTarget:self 
        action:@selector(infoButtonAction:) 
     forControlEvents:UIControlEventTouchUpInside]; 
    infoButton.frame = CGRectMake(280.0, 420.0, 20.0, 20.0); 
    [self.view addSubview:infoButton]; 
} 

- (IBAction)infoButtonAction:(id)sender 
{ 
    NSLog(@"info clicked"); 
    // What should I add here? 
} 

謝謝!

回答

3

信息按鈕通常呈現一個水平翻轉過渡的模態視圖控制器。查看天氣和股票應用程序以及Xcode的「實用程序應用程序」項目模板。

編輯:示例代碼

你會創建UIViewController一個新的子類來顯示您的信息。提出它的代碼(而不是故事情節塞格斯),你可以這樣做:

- (IBAction)infoButtonAction:(id)sender 
{ 
    InfoViewController *infoViewController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil]; 
    infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentViewController:infoViewController animated:YES completion:nil]; 
} 

然後,你可以連接一臺完成按鈕來關閉它:

- (IBAction)doneButtonTapped:(id)sender 
{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 
+0

謝謝!這正是我在這個YouTube教程http://www.youtube.com/watch?v=zzay_bHVBS0中發現的。 – 2011-12-29 23:07:59

相關問題