【问题标题】:Action Sheet Within ActionSheetActionSheet 中的 Action Sheet
【发布时间】:2012-08-08 02:40:47
【问题描述】:

我是 Objective C 和 iPhone 开发的新手。 请告诉我如何在操作表中添加操作表。 就像当我点击一个按钮时,一个动作表被打开,然后我单击第一个 ButtonIndex 动作,另一个动作表出现。 请提及完整的代码。 谢谢

【问题讨论】:

  • 操作表出现,但未选择 buttonIndex。动作仍然发生在第一个动作表上。

标签: iphone xcode uiactionsheet


【解决方案1】:

使用UIActionSheet 委托方法:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0) { // Add an action sheet for one of these buttons -> maybe here if you want...

     NSLog(@"You clicked the first button...");

     UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Another action sheet"
     delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive" 
     otherButtonTitles:@"Other Button 1", nil];

    popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;

    [popupQuery showInView:self.view];

    [popupQuery release];

    } 

    else {

        NSLog(@"Dismissing action sheet");

    }

}

【讨论】:

    【解决方案2】:

    您要做的就是关闭第一个 UIActionSheet 并在其位置显示另一个 UIActionSheet。换句话说,您不想在另一个 UIActionSheet 显示 UIActionSheet - 您想在另一个 UIActionSheet 被解除后显示 UIActionSheet。

    要了解何时关闭操作表,您应该实现UIActionSheetDelegate 协议。例如:

    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    // first action sheet is dismissed
    // show a new action sheet here
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-20
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      相关资源
      最近更新 更多