iOS开发-UIAlerView
来源:互联网 发布:ubuntu14.04安装mysql 编辑:程序博客网 时间:2024/04/26 02:58
警告提示视图
NSString *content = NSLocalizedString(@"this is test alert message", nil);UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"alert title", nil) message:content delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", nil) otherButtonTitles:NSLocalizedString(@"ok", nil), nil]; alert.tag = 1; //用来作为标识,可区分不同的提示框 [alert show];
在使用的类里,实现代理协议UIAlertViewDelegate
按钮点击处理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { switch(buttonIndex){ case 0: //do cancel break; case 1: //do ok break; }}
在UIAlertView显示动画之前,改变提示message的对其方式,改为左对齐
- (void)willPresentAlertView:(UIAlertView *)alertView{ //遍历UIAlertView的子视图,改变label的大小,尺寸,和对齐方式 for(UIView *subview in alertView.subviews) { if([[subview class] isSubclassOfClass:[UILabel class]]) { if(![((UILabel *)subview).text isEqualToString:iGexinLocalizedString(@"file detail", nil)]){ UILabel *label = (UILabel*)subview; CGRect rect = CGRectInset(label.frame, 20, 0); //label边界留20 NSString * labelText = label.text; CGFloat oldH = rect.size.height; rect.size = [labelText sizeWithFont:label.font constrainedToSize: CGSizeMake(rect.size.width, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap]; //计算文本的宽度和高度 if(oldH < rect.size.height){ rect.origin.y -= 10; } label.frame = rect; //调整label的位置和尺寸 label.textAlignment = UITextAlignmentLeft; //label文本左对齐 break; } } }}
- IOS开发之UIAlerView
- iOS开发-UIAlerView
- ios开发
- ios开发
- iOS开发
- IOS开发
- iOS开发
- iOS开发
- iOS开发
- ios 开发
- IOS开发
- ios开发
- ios开发
- iOS开发
- ios开发
- iOS-开发
- iOS开发
- ios开发
- stl容器--总结
- 表格的导入
- CodeIgniter的中的一些基本数据库操作的demo
- phptest
- HDU 3697 暴力贪心
- iOS开发-UIAlerView
- 装饰模式lua实现
- Atomikos 性能提高8倍
- c++中函数参数传递(值传递、指针传递,引用传递)进一步认识
- ROWID
- 巧用Graphviz和pvtrace等工具可视化C函数调用
- VC6.0找不到控件工具条
- 查看tomcat为jvm分配的内存大小
- 3G模块PPPD拨号流程分析