2013-01-11 47 views
1

我不知道該搜索什麼或調用什麼,因爲我是全新的。請按我的按鈕時,它會顯示其他按鈕。我們在很多應用程序中發現它,但我不知道名稱。我在下面附上了它的照片。我如何在iOS應用程序中執行此操作。如何在iOS應用程序中按下按鈕時列出按鈕

Options

+1

刪除了Xcode的提及,因爲您的問題與IDE無關並與iOS有關。 –

+0

這是一個'UIActionSheet'。如果您想開發iOS應用程序,我建議您開始閱讀必備內容 - [iOS應用程序編程指南](http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/) iPhoneOSProgrammingGuide/Introduction/Introduction.html)和[iOS人機界面指南](http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/Introduction/Introduction.html)。 –

回答

2

正所謂UIActionSheet

這裏是一個評價者複雜的例子:

UIActionSheet *actionSheet = [[UIActionSheet alloc] init] ; 
    actionSheet.title = @"Change pincode?"; 
    actionSheet.delegate = self; 
    actionSheet.tag = kChangePincode; 

    [actionSheet addButtonWithTitle:@"Chacge pincode"]; 
    [actionSheet addButtonWithTitle:@"Remove pin code"]; 

    [actionSheet addButtonWithTitle:@"cancel"]; 
    [actionSheet setCancelButtonIndex:(actionSheet.numberOfButtons - 1)]; 

    [actionSheet showInView:self.view]; 
+0

感謝此代碼...也可以從http://mobiledevelopertips.com/user-interface/simple-menus-and-messages-with-uiactionsheet.html獲取幫助。 – user777304

0

經過UIActionsheet. 不要加試這樣

//在.H類

@interface MyViewController : UIViewController <UIActionSheetDelegate> { 

    ... 

} 


... 


-(IBAction)showActionSheet:(id)sender; 

@end

In .m

-(IBAction)showActionSheet:(id)sender { 
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", @"Other Button 2", nil]; 
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque; 
    [popupQuery showInView:self.view]; 
    [popupQuery release]; 
} 


// Handle Delegates------------- 
    -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
     if (buttonIndex == 0) { 
      self.label.text = @"Destructive Button Clicked"; 
     } else if (buttonIndex == 1) { 
      self.label.text = @"Other Button 1 Clicked"; 
     } else if (buttonIndex == 2) { 
      self.label.text = @"Other Button 2 Clicked"; 
     } else if (buttonIndex == 3) { 
      self.label.text = @"Cancel Button Clicked"; 
     } 

     /** 
     * OR use the following switch statement 
     * 
     */ 
     /* 
     switch (buttonIndex) { 
      case 0: 
       self.label.text = @"Destructive Button Clicked"; 
       break; 
      case 1: 
       self.label.text = @"Other Button 1 Clicked"; 
       break; 
      case 2: 
       self.label.text = @"Other Button 2 Clicked"; 
       break; 
      case 3: 
       self.label.text = @"Cancel Button Clicked"; 
       break; 
     } 
     */ 
    } 
相關問題