本文介绍了创建UIActionSheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建这种菜单,当然还有其他菜单按钮。是否有任何默认的viewcontroller表示它,或者我必须自己获取图像并创建它。
I would like to create this kind of menu, of course with other menu buttons. Is there any default viewcontroller representing it, or do I have to get images and create this by myself.
推荐答案
您需要使用 UIActionSheet
。
首先,您需要将 UIActionSheetDelegate
添加到ViewController.h中文件。
First you need to add UIActionSheetDelegate
to your ViewController.h file.
然后你可以引用一个动作表:
Then you can reference an actionsheet with:
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select Sharing option:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:
@"Share on Facebook",
@"Share on Twitter",
@"Share via E-mail",
@"Save to Camera Roll",
@"Rate this App",
nil];
popup.tag = 1;
[popup showInView:self.view];
然后你必须处理每个电话。
Then you have to handle each of the calls.
- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (popup.tag) {
case 1: {
switch (buttonIndex) {
case 0:
[self FBShare];
break;
case 1:
[self TwitterShare];
break;
case 2:
[self emailContent];
break;
case 3:
[self saveContent];
break;
case 4:
[self rateAppYes];
break;
default:
break;
}
break;
}
default:
break;
}
}
这已被推荐用于iOS 8.x
This has been deprecated for iOS 8.xhttps://developer.apple.com/documentation/uikit/uialertcontroller#//apple_ref/occ/cl/UIAlertController
这篇关于创建UIActionSheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!