Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 创建弹出按钮界面_Ios_Objective C_Cocoa Touch_Button - Fatal编程技术网

Ios 创建弹出按钮界面

Ios 创建弹出按钮界面,ios,objective-c,cocoa-touch,button,Ios,Objective C,Cocoa Touch,Button,在苹果的股票“信息”应用程序中,点击相机按钮会显示弹出按钮,允许用户拍摄照片/视频或选择现有的照片/视频。我将如何实现同样的按钮设计?iPhone和iPad的操作程序都一样吗?它被称为UIActionSheet。你是这样用的 UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Foo" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil

在苹果的股票“信息”应用程序中,点击相机按钮会显示弹出按钮,允许用户拍摄照片/视频或选择现有的照片/视频。我将如何实现同样的按钮设计?iPhone和iPad的操作程序都一样吗?

它被称为
UIActionSheet
。你是这样用的

UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Foo" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"foo1", @"foo2", nil];
[action showInView:self.view];
(将foos更改为which)。要检测单击的按钮,请执行
UIActionSheetDelegate
actionSheet:ClickedButtonIndex:
delegate方法。例如:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];
    if ([title isEqualToString:@"foo1"]) {
        // do stuff...
    }
}

是的,这在iPhone和iPad上都有效(正如@bobnoble所指出的,iPad版本使用的是popover视图,而不是动作表,但动作表在两者上都有效)。

在iPad上,在popover中显示
UIActionSheet
,与在iPad版本中显示的消息相同。在iPhone上,您可能需要添加一个“取消”按钮。