关于ios 中 UIAlertView
来源:互联网 发布:jdk1.6 linux rpm bin 编辑:程序博客网 时间:2024/05/21 06:54
在iOS7中靠列举alertview中的对像修改alertview已经不行了
//在iOS6中创建AlertView,
UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:@"这里是提示标题" message:@"这里是提示内容" delegate:self cancelButtonTitle:@"最下边的按钮" otherButtonTitles:@"按钮1",@"按钮2",@"按钮3",nil];
//alertView1.delegate = self;//代理可以在创建以后再设置,也可以在创建时直接设置,但是必须在show之前(不然一个代理方法不执行)。[alertView1 show];
[alertView1 release];
//以下6个方法为alertview的代理方法- (void)alertViewCancel:(UIAlertView *)alertView
{
//在点击home键的时候执行,模拟器里测试不出来
NSLog(@"取消是运行 ---%d",alertView.tag);
}
- (void)willPresentAlertView:(UIAlertView *)alertView
{
//如果在show之后,设置代理则不会执行了。
NSLog(@"将要显示的时候运行 ---%d",alertView.tag);//可以对alertview做简单的自定义,如下
CGRect frame = alertView.frame;
if( alertView == alertView1 )//如果alertView就是声明的alertView1
{
frame.origin.y -= 80;
frame.size.height += 80;
alertView.frame = frame;
for( UIView * view in alertView.subviews )//列举alertView中所有的对象
{
if( ![view isKindOfClass:[UILabel class]] )//如果对象不是UILabel
{
//isKindOfClass判断不是UILable的,则另行处理
if (view.tag==1){
//处理第一个按钮CancelButton进行设置
CGRect btnFrame1 =CGRectMake();
view.frame = btnFrame1;
} else if (view.tag==2){
//处理第二个按钮otherButton
CGRect btnFrame2 =CGRectMake();
view.frame = btnFrame2;
} else if (view.tag==3){
//处理第三个按钮otherButton
CGRect btnFrame2 =CGRectMake();
view.frame = btnFrame2;
view.backgroundColor = [UIColor redColor];
}
}
}
}
//在alertVIew上添加按钮
//UIButton *but = [[UIButton alloc] initWithFrame:CGRectMake((frame.size.width-100)/2, frame.size.height/2, 100, 40)];
// but.backgroundColor = [UIColor greenColor];
// [but addTarget:self action:@selector(butclick) forControlEvents:UIControlEventTouchUpInside];
// [alertView addSubview:but];
text = [[UITextField alloc] initWithFrame:CGRectMake(40, 100, 200, 40)];
text.borderStyle = UITextBorderStyleRoundedRect;
text.keyboardType = UIKeyboardTypeNumberPad;//改变键盘的类型
[alertView addSubview:text];
}
-(void)butclick
{
NSLog(@"%@",text.text);
NSLog(@"234");
[alertView1 dismissWithClickedButtonIndex:0 animated:YES];
}
// before animation and showing view
- (void)didPresentAlertView:(UIAlertView *)alertView
{// after animation
NSLog(@"已经显示后执行该方法 -----%@",alertView.title);
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"被点击的时候执行该方法----%d",buttonIndex);
}
// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{// before animation and hiding view
NSLog(@"将要消失执行该方法 ----%@",alertView.message);
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{// after animation
NSLog(@"已经消失执行该方法 -----%d === %d",alertView.tag,buttonIndex);
}
如有错误,请大鸟指点
- 关于ios 中 UIAlertView
- iOS中“函数式”UIAlertView
- iOS中UIAlertView的使用方法
- iOS 中 Block实现UIAlertView
- iOS 关于UIAlertController、UIAlertView弹窗问题
- ios 关于UIAlertView与UIActionSheet的区别,以及在使用过程中注意事项
- UIAlertView中显示进度条 ios iphone xcode
- iOS在UIAlertView中实现UIProgress进度条
- iOS中UIAlertView的点击响应事件
- iOS 中UIAlertView 的简单使用
- IOS UIAlertView
- iOS UIAlertView
- ios UIAlertView
- iOS---UIAlertView
- IOS UIAlertView
- ios UIAlertView
- 关于iOS 7以后自定义UIAlertview(CustomIOS7AlertView)的用法心得
- IOS 中UIAlertView中获取自定义文本框文字方法
- wcscpy ;wcscmp
- 在linux下搭建SVN服务器,权限+常见错误
- android上传文件和参数到web服务器,php接收并保存
- Ant tool in Eclipse
- 十项全能|引领业界-逐浪CMS3.1隆重发布
- 关于ios 中 UIAlertView
- Android tools dumpsys
- C++函数式编程(六)行动指导
- AJAX中同时发送多个请求(并发)对象处理方法
- oracle 修改密码
- shell 与 命令的执行
- 深圳南山科技园一公司年终发10台高尔夫奖优秀员工
- 查看Oracle数据库名和实例名
- Recursive entry to executePendingTransactions