UIAlertView 和 UIActionSheet简单应用
来源:互联网 发布:广联达软件难学吗 编辑:程序博客网 时间:2024/05/02 09:42
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
[selfUIActionSheetButton];
[selfAlertViewButton];
}
#pragma mark - UIActionSheet
- (void)UIActionSheetButton
{
/* 创建一个 button */
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(40, 60, 300, 40);
button.backgroundColor = [UIColorcyanColor];
[button setTitle:@"UIActionSheet效果"forState:UIControlStateNormal];
[self.viewaddSubview:button];
/* 添加点击事件 */
[button addTarget:selfaction:@selector(buttonClicked:)forControlEvents:UIControlEventTouchUpInside];
}
- (void)buttonClicked:(UIButton *)button
{
/* UIActionSheet
* initWithTitle: 设置标题, 将会显示在 ActionSheet 的顶部
* delegate: 设置 ActionSheet的一个按钮被按下后, 它的 delegate 将会被通知, 并且这个 delegate 的 actionSheet : didDismissWithButtonIndex方法将会执行.
* cancelButtonTitle: 设置取消按钮的标题,这个按钮将会显示在最下面
* destructiveButtonTitle: 设置第一个确定按钮的标题,这个按钮可以理解成"好的,继续"
* otherButtonTitles: 可以设置任意多的确定按钮
*/
UIActionSheet *action = [[UIActionSheetalloc] initWithTitle:@"你喜欢我吗?"delegate:selfcancelButtonTitle:@"不是不是的"destructiveButtonTitle:@"是的,我喜欢你啊!"otherButtonTitles:@"",nil];
[action showInView:self.view];
}
#pragma mark - AlertView
- (void)AlertViewButton
{
/* 创建 button 对象 */
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(40, 120, 300, 40);
button.backgroundColor = [UIColorcyanColor];
[button setTitle:@"UIAlertView效果"forState:UIControlStateNormal];
[self.viewaddSubview:button];
/* 添加点击事件 */
[button addTarget:selfaction:@selector(button1Clicked:)forControlEvents:UIControlEventTouchUpInside];
}
- (void)button1Clicked:(UIButton *)button1Clicked
{
/* UIAlertView
* initWithTitle: 设置标题, 将会显示在 Alert 的顶部
* message: 设置提示消息内容
* delegate: 设置 Alert 的委托, 这里设为 self
* cancelButtonTitle: 设置取消按钮的标题
* otherButtonTitles: 设置多个按钮
*/
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"完美告白"message:@"我喜欢你呀"delegate:selfcancelButtonTitle:@"好的"otherButtonTitles: nil];
[alert show];
}
# pragma mark - UIAlertView 和 UIActionSheet的不同
/* Alert 相当于 Windows 中的 Messagebox , 跟 Action Sheet也是类似. 不同的是, Alert可以只有一个选择项, 而 Action Sheet 却至少要两个选项 */
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self UIActionSheetButton];
[self AlertViewButton];
}
#pragma mark - UIActionSheet
- (void)UIActionSheetButton
{
/* 创建一个 button */
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(40, 60, 300, 40);
button.backgroundColor = [UIColor cyanColor];
[button setTitle:@"UIActionSheet 效果" forState:UIControlStateNormal];
[self.view addSubview:button];
/* 添加点击事件 */
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)buttonClicked:(UIButton *)button
{
/* UIActionSheet
* initWithTitle: 设置标题, 将会显示在 ActionSheet 的顶部
* delegate: 设置 ActionSheet 的一个按钮被按下后, 它的 delegate 将会被通知, 并且这个 delegate 的 actionSheet : didDismissWithButtonIndex 方法将会执行.
* cancelButtonTitle: 设置取消按钮的标题, 这个按钮将会显示在最下面
* destructiveButtonTitle: 设置第一个确定按钮的标题, 这个按钮可以理解成"好的, 继续"
* otherButtonTitles: 可以设置任意多的确定按钮
*/
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"你喜欢我吗?" delegate:self cancelButtonTitle:@"不是不是的" destructiveButtonTitle:@"是的, 我喜欢你啊!" otherButtonTitles:@"", nil];
[action showInView:self.view];
}
#pragma mark - AlertView
- (void)AlertViewButton
{
/* 创建 button 对象 */
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(40, 120, 300, 40);
button.backgroundColor = [UIColor cyanColor];
[button setTitle:@"UIAlertView 效果" forState:UIControlStateNormal];
[self.view addSubview:button];
/* 添加点击事件 */
[button addTarget:self action:@selector(button1Clicked:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)button1Clicked:(UIButton *)button1Clicked
{
/* UIAlertView
* initWithTitle: 设置标题, 将会显示在 Alert 的顶部
* message: 设置提示消息内容
* delegate: 设置 Alert 的委托, 这里设为 self
* cancelButtonTitle: 设置取消按钮的标题
* otherButtonTitles: 设置多个按钮
*/
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"完美告白" message:@"我喜欢你呀" delegate:self cancelButtonTitle:@"好的" otherButtonTitles: nil];
[alert show];
}
# pragma mark - UIAlertView 和 UIActionSheet 的不同
/* Alert 相当于 Windows 中的 Messagebox , 跟 Action Sheet 也是类似. 不同的是, Alert可以只有一个选择项, 而 Action Sheet 却至少要两个选项 */
- UIAlertView 和 UIActionSheet简单应用
- IOS-UIAlertView和UIActionSheet
- UIActionSheet和UIAlertView
- UIAlertView和UIActionSheet
- UIAlertView和UIActionSheet
- IPHONE应用开发 - 开发常用控件:UIActionSheet和UIAlertView学习
- IPHONE应用开发 - 开发常用控件:UIActionSheet和UIAlertView学习
- Iphone之UIAlertView和UIActionSheet
- UIAlertController,取代UIAlertView和UIActionSheet
- UIAlertview UIActionSheet
- UIAlertView&UIActionSheet
- UIAlertView、UIActionSheet
- UIAlertView、UIActionSheet
- iOS开发 对话框UIActionSheet和UIAlertView用法
- 介绍UIALertView和UIActionSheet的用法。
- iOS开发 对话框UIActionSheet和UIAlertView用法
- iOS UIAlertView和UIActionSheet的用法
- 介绍UIALertView和UIActionSheet的用法。
- android:clipToPadding和android:clipChildren的解析
- Android应用开发之所有动画使用详解
- 线程的安全
- 预格式文本的作用
- SQL Server 2008 分区函数和分区表操作方法
- UIAlertView 和 UIActionSheet简单应用
- Windows系统相关资料整理
- Ubuntu安装搜狗输入法
- 机房收费系统-组合查询
- HDU 3341 Lost's revenge(AC自动机+状态压缩DP)
- 【黑马程序员-学习笔记】OC-协议与分类
- c语言实现魔方阵算法
- HOGDescriptor 参数解释 OpenCV
- MyEclipse JVM内存