ios 关于UIAlertView与UIActionSheet的区别,以及在使用过程中注意事项
2016-04-11 13:49
761 查看
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"hello" message:@"I'm Apple" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil]; [alert show]; [alert release];
有多个按钮的时候
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"hello" message:@"O哈啊" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel",@"Ignore",nil ];
UIAlertViewDelegate 中的
- (void) alertView:(UIAlertView *)alertview
clickedButtonAtIndex:(NSInteger)buttonIndex
方法可以知道你点的是那个按钮。
UIActionSheet是从屏幕底部弹起的一个模态对话框,它的使用也很简单
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?" delegate:self cancelButtonTitle:@"No Way!" destructiveButtonTitle:@"Yes, I'm sure!" otherButtonTitles:nil]; [actionSheet showInView:self.view];(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 代理方法,知道你点击了那个按钮
注意:在iphone和ipad上使用UIActionShee控件t的效果会不一样,在苹果的官方文档中有相关说明:
在ipad上使用UIActionSheet控件改控件不再从底部弹出,而是从屏幕中间弹出与UIAlertView警告框弹出有点类似。效果如图所示,cancelButton按钮文字显示不出来,destructiveButtonTitle按钮文字为红色加粗字体
相关文章推荐
- iOS: Autolayout和UITableViewCell的动态高度 (1)
- java.net.BindException: Cannot assign requested address: bind
- UITableViewCell在重用ID时为何加上Static关键字
- 人工智能短故事:认知非连续Short Story on AI: A Cognitive Discontinuity
- java.awt.EventQueue.invokeLater(new Runnable(){public void run(){}})(三)
- java.awt.EventQueue.invokeLater(new Runnable(){public void run(){}})(一)
- Java GUI:图形用户界面三剑客相比拼
- ZOj 3929 Deque and Balls
- 【POJ 2831】 Can We Build This One?(prim 最小生成树变形)
- UIImageView添加圆角优化
- iOS手势操作UIGestureRecognizer
- iOS的UDID废用以及UUID配合keychain的替换方案实现
- (绝对有用)iOS获取UUID,并使用keychain存储
- mysql error 1364 Field doesn't have a default values
- android UiAutomation
- event.returnValue和return false的区别
- 22. Generate Parentheses My Submissions QuestionEditorial Solution
- dulib 扩展CTileLayoutUI支持竖排,类似桌面展示
- 前端框架OnsenUI学习之ng-repeat和ons-lazy-repeat介绍
- 前端框架OnsenUI学习之<ons-page>介绍