我们点击UIActionSheet(iPhone App)中的按钮是否可以打开一个新视图?

时间:2011-01-13 21:05:19

标签: objective-c uiactionsheet

是否可以在UIActionSheet中单击按钮打开新视图?

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



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

提前谢谢

1 个答案:

答案 0 :(得分:1)

是的,当然。如果用户按下UIButton对象,您可以像添加视图一样添加视图。 (例如,以模式方式推送视图控制器,或使用[self.view addSubview:viewN]

将所需视图添加到视图层次结构中