iphone开发 UIActionSheet(操作表) 和UIAlertView(警告)的用法
一.UIActionSheet(操作表) 和UIAlertView(警告)
UIActionSheet用于迫使用户在两个或更多的选项之间进行选择的模式视图。操作表从屏幕底部弹出,显示一系列按钮供用户选择,用户只有单击一个按钮后才能继续使用应用程序。
UIAlertView警告以蓝色圆角矩形形式出现在屏幕中部,警报可显示一个或多个按钮
为了让控制器类充当操作表的委托,控制器需要遵从UIActionSheetDelegate协议
二.UIActionSheet(操作表)的创建
initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:
注释:initWithTitle是对象函数
initWithTitle:操作表标题
delegate:接收对象
cancelButtonTitle关闭按钮标题
destructiveButtonTitle: 操作按钮标题
otherButtonTitles:其他按钮
1. 创建一个简单的操作表:
//open a dialog with an OK and cancel button
UIActionSheet*actionSheet = [[UIActionSheet alloc]
initWithTitle:@" UIActionSheet<title>"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"OK"
otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheetshowInView:self.view]; //show from our table view (pops up in the middle of the table)
[actionSheetrelease];
2. 创建两个按钮的操作表
// open a dialog with an OKand cancel button
UIActionSheet*actionSheet = [[UIActionSheet alloc]
initWithTitle:@" UIActionSheet<title>"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"OK"
otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheetshowInView:self.view]; //show from our table view (pops up in the middle of the table)
[actionSheetrelease];
3. 创建自定义操作表:
//open a dialog with two custom buttons
UIActionSheet*actionSheet = [[UIActionSheet alloc]
&nbs
相关新闻>>
- 发表评论
-
- 最新评论 更多>>