UIALertView的使用
2016-02-23 15:12
411 查看
//
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//这里根据点击的NSInteger值来判断点击了那个按钮
NSLog(@”clickButtonAtIndex:%d”,buttonIndex);
}
//AlertView已经消失时执行的事件
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@”didDismissWithButtonIndex”);
}
//ALertView即将消失时的事件
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@”willDismissWithButtonIndex”);
}
//AlertView的取消按钮的事件
-(void)alertViewCancel:(UIAlertView *)alertView
{
NSLog(@”alertViewCancel”);
}
//AlertView已经显示时的事件
-(void)didPresentAlertView:(UIAlertView *)alertView
{
NSLog(@”didPresentAlertView”);
}
//AlertView即将显示时
-(void)willPresentAlertView:(UIAlertView *)alertView
{
NSLog(@”willPresentAlertView”);
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib
//初始化AlertView UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"AlertViewTest" message:@"message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OtherBtn",nil]; //设置标题与信息,通常在使用frame初始化AlertView时使用 alert.title = @"AlertViewTitle"; alert.message = @"AlertViewMessage"; //这个属性继承自UIView,当一个视图中有多个AlertView时,可以用这个属性来区分 alert.tag = 0; //只读属性,看AlertView是否可见 NSLog(@"%d",alert.visible); //通过给定标题添加按钮 [alert addButtonWithTitle:@"addButton"]; //按钮总数 NSLog(@"number Of Buttons :%d",alert.numberOfButtons); //获取指定索引的按钮标题 NSLog(@"buttonTitleAtIndex1:%@",[alert buttonTitleAtIndex:1]); NSLog(@"buttonTitleAtIndex2:%@",[alert buttonTitleAtIndex:2]); //获取取消按钮的索引 NSLog(@"cancelButtonIndex:%d",alert.cancelButtonIndex); //获取第一个其他按钮的索引 NSLog(@"firstOtherButtonIndex:%d",alert.firstOtherButtonIndex); //显示AlertView [alert show]; [alert release];
}
pragma marks – UIAlertViewDelegate –
//根据被点击按钮的索引处理点击事件-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//这里根据点击的NSInteger值来判断点击了那个按钮
NSLog(@”clickButtonAtIndex:%d”,buttonIndex);
}
//AlertView已经消失时执行的事件
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@”didDismissWithButtonIndex”);
}
//ALertView即将消失时的事件
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@”willDismissWithButtonIndex”);
}
//AlertView的取消按钮的事件
-(void)alertViewCancel:(UIAlertView *)alertView
{
NSLog(@”alertViewCancel”);
}
//AlertView已经显示时的事件
-(void)didPresentAlertView:(UIAlertView *)alertView
{
NSLog(@”didPresentAlertView”);
}
//AlertView即将显示时
-(void)willPresentAlertView:(UIAlertView *)alertView
{
NSLog(@”willPresentAlertView”);
}
相关文章推荐
- UiAutomator 测试环境搭建
- <%@ page trimDirectiveWhitespaces="true" %>
- POJ 2524 Ubiquitous Religions(简单的并查集题目)
- 图片动画
- masonry+UIScrollView+UICollectionView自动布局偶尔向下偏移的问题
- UIViewController界面跳转时的值传递
- UIView
- easyUI 中datagrid控件从后台获取数据生成列,想让其中部分属性数据不在表中显示
- 我的Android进阶之旅------>解决:Failed to create 'build\outputs\apk\watch-debug-unaligned.apks': 拒绝访问。
- VS2008LINK : fatal error LNK1000: Internal error during IncrBuildImage
- bluetooth-蓝牙事件监听
- CoreBluetooth第二节:Performing Common Peripheral Role Task(执行常见的外设端任务)
- iOS开发技巧(系列十二:UUID和UDID的区别)
- mui如何增加自定义字体icon图标
- 详解 CALayer 和 UIView 的区别和联系
- iOS 5.0 后UIViewController新增:willMoveToParentViewController和didMoveToParentViewController
- easyUI 中datagrid控件demo,包括选中一行能读取到数据
- UIView和CALayer的区别 说的比较清楚了
- iOS-UItableview 分割线(自定义+原生)方法总结
- UI整理-----part7--模态视图 push&pop