2009-07-17 46 views
0

我一直在嘗試這一個今晚一段時間....我有一個UIActionSheet在它自己的控制器。我在導入控制器的視圖中,我希望它被顯示。我無法弄清楚當用戶按下其中一個按鈕時,如何顯示一個新的視圖(您可以看到我現在只發送一個警報的位置)。有任何想法嗎?UIActionSheet Button加載一個新視圖

- (void)helpButtonPressedView { 
    // open a dialog with two custom buttons 
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" 
                delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil 
                otherButtonTitles:@"Help", @"Credits", nil]; 
    [self parentViewController]; 
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault; 
    [actionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table) 
    [actionSheet release]; 
} 

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    NSLog(@"Button Pressed: %d",buttonIndex); 

    int btn = buttonIndex; 

    UIAlertView *alert; 

    switch (btn) { 
     case 0: 
      // help screen 
      alert = [[UIAlertView alloc] initWithTitle:@"Button Press Notice" message:@"The Help screen will be dispayed" 
                  delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
      [alert show]; 
      [alert release]; 

//   helpViewController = [[HelpViewController alloc] init]; 
//   [self presentModalViewController:helpViewController animated:YES]; 

      break; 
     case 1: 
      // credits screen 
      alert = [[UIAlertView alloc] initWithTitle:@"Button Press Notice" message:@"The Credits screen will be dispayed" 
               delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
      [alert show]; 
      [alert release];    
      break; 
     default: 
      break; 
    } 

} 

這是我正在嘗試做的事情的照片......當用戶按下「幫助」按鈕時,顯示一個新的視圖。當用戶按下「Credits」按鈕時會顯示不同的視圖。我正在使用IB來創建視圖。

alt text http://thecoolestcompany.com/UIActionSheet-view.jpg

+0

如果您稍微解釋一下您試圖在視覺上做什麼,這將會有所幫助。 – 2009-07-17 05:05:09

回答

0

它已經有一段時間我問這個問題 - 我想它出了一陣子....我錯過了導航控制器做推視圖控制器。換句話說,創建視圖控制器,然後使用導航控制器推動視圖。如果有人正在閱讀本文並需要示例代碼,請發帖反對該問題,並且我將發佈示例代碼...

0

取而代之的警報,你可以創建你的觀點,並把它添加到當前視圖:

UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(100,100,100,100)]; 
[self.view addSubview:newView]; 
[newView release]; 
+1

通過創建新視圖替換警報不起作用。 – 2009-07-17 09:58:10