用UIAlertView绘制弹出对话框
来源:互联网 发布:mac mini 装win10 编辑:程序博客网 时间:2024/05/20 21:44
如果想使用UIAlertView定制自己的对话框,要添加系统回调函数- (void)willPresentAlertView:(UIAlertView *)alertView,并在这个函数中加入自己想要的内容,代码如下:
- (void)viewDidLoad{
myalertView = [[UIAlertView alloc]initWithTitle:@"配置ip"
message:@""
delegate:self
cancelButtonTitle:@"cancel"
otherButtonTitles:@"ok",nil];
//myalertView.userInteractionEnabled = YES;
[myalertView show];
}
//adjust the appearance of alertView
- (void)willPresentAlertView:(UIAlertView *)alertView{
alertView.frame = CGRectMake(alertView.frame.origin.x, alertView.frame.origin.y-80,alertView.frame.size.width , alertView.frame.size.height+130);
//add labels
//label:ip
UILabel *label_IP = [[UILabel alloc] initWithFrame:CGRectMake(20, 30, 140, 20)];
label_IP.text = @"IP Address:";
label_IP.backgroundColor = [UIColor clearColor];
label_IP.textColor = [UIColor whiteColor];
[alertView addSubview:label_IP];
[label_IP release];
//label:getway
UILabel *label_GW = [[UILabel alloc] initWithFrame:CGRectMake(20, 80, 140, 20)];
label_GW.text = @"Geteway:";
label_GW.backgroundColor = [UIColor clearColor];
label_GW.textColor = [UIColor whiteColor];
[alertView addSubview:label_GW];
[label_GW release];
//label:subnet mask
UILabel *label_SubM = [[UILabel alloc] initWithFrame:CGRectMake(20, 130, 140, 20)];
label_SubM.text = @"Subnet Mask:";
label_SubM.backgroundColor = [UIColor clearColor];
label_SubM.textColor = [UIColor whiteColor];
[alertView addSubview:label_SubM];
[label_SubM release];
for (UIView *Outlet in [alertView subviews])
{
if(![Outlet isKindOfClass:[UITextField class]]&&![Outlet isKindOfClass:[UILabel class]])
{
UIButton* button = (UIButton*)Outlet;
button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y+130,button.frame.size.width , button.frame.size.height);
}
}
//textField:ip
textField_IP = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 240, 20)];
[alertView addSubview:textField_IP];
textField_IP.backgroundColor = [UIColor whiteColor];
//[textField_IP release];
//textField:getway
textField_GW = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 240, 20)];
[alertView addSubview:textField_GW];
textField_GW.backgroundColor = [UIColor whiteColor];
//[textField_GW setSecureTextEntry:YES];
//[textField_GW release];
//textField:subnet mask
textField_SubM = [[UITextField alloc] initWithFrame:CGRectMake(20, 150, 240, 20)];
[alertView addSubview:textField_SubM];
textField_SubM.backgroundColor = [UIColor whiteColor];
//[textField_SubM setSecureTextEntry:YES];
//[textField_SubM release];
}
//按钮响应函数
//- (void)alertView:(UIAlertView *)alertView clickdButtonAtIndex:(NSInteger)buttonIndex
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"ok"]) {
IP = textField_IP.text;
Getway = textField_GW.text;
SubnetMask = textField_SubM.text;
}
- 用UIAlertView绘制弹出对话框
- 对话框UIAlertView
- IOS-- UIAlertView(对话框)
- UIAlertController & UIAlertView 对话框
- 用JS弹出网页对话框
- 用easyui弹出消息对话框
- 模拟uialertview制作弹出视图
- 自动关闭UIAlertView弹出框
- UIAlertView弹出视图动画效果
- IOS 实现UIAlertView弹出动画
- UIAlertView弹出视图动画效果
- 仿 UIAlertView 弹出动画效果
- 模仿UIAlertView,iOS模式对话框
- Android仿IOS UIAlertView对话框
- Android仿IOS UIAlertView对话框
- Android仿IOS UIAlertView对话框
- Android仿IOS UIAlertView对话框
- 弹出对话框
- YUM常用命令介绍
- EJB与JavaBean之区别
- 影像店管理建库脚本 cdshop.sql
- Android Dev Guide -> User Interface
- 请记住这一天2011/5/8
- 用UIAlertView绘制弹出对话框
- 【转】LaTeX制作pdf文件书签乱码问题
- 什么是分布式应用开发
- 进程线程及堆栈关系的总结
- FireFox3中input file
- DSP中GEL文件的作用
- PHP导出EXCEL快速开发指南--PHPEXCEL
- 使用源代码设置控件位置/隐藏tabbar
- javascript的对象创建和使用