点击6次修改服务器地址
2015-09-28 12:07
302 查看
在全局UINavigationController中添加如下代码
- (void)viewDidLoad {
[self addHeaderTouch];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)addHeaderTouch
{
self.navigationBar.topItem.titleView.backgroundColor = [UIColor redColor];
NSLog(@"%@",self.navigationController.navigationBar);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchTap:)];
tap.numberOfTapsRequired = 6;
[self.navigationBar addGestureRecognizer:tap];
}
- (IBAction)touchTap:(UITapGestureRecognizer *)tap
{
NSLog(@"touchTap");
[self showActionView];
}
- (void)showActionView
{
NSLog(@"showActionView");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"设置服务器IP" message:@"\n【确定】切换到指定IP\n【线上】切换到线上服务器" delegate:self cancelButtonTitle:@"线上" otherButtonTitles:@"确定", nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
self.inputText = [alert textFieldAtIndex:0];
self.inputText.text = @"192.168.";
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [alertView cancelButtonIndex]) {
NSLog(@"线上");
[APPConfig setServerIp:@"线上服务器地址"];
}else {
[APPConfig setServerIp:self.inputText.text];
NSLog(@"确定");
}
}
- (void)viewDidLoad {
[self addHeaderTouch];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)addHeaderTouch
{
self.navigationBar.topItem.titleView.backgroundColor = [UIColor redColor];
NSLog(@"%@",self.navigationController.navigationBar);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchTap:)];
tap.numberOfTapsRequired = 6;
[self.navigationBar addGestureRecognizer:tap];
}
- (IBAction)touchTap:(UITapGestureRecognizer *)tap
{
NSLog(@"touchTap");
[self showActionView];
}
- (void)showActionView
{
NSLog(@"showActionView");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"设置服务器IP" message:@"\n【确定】切换到指定IP\n【线上】切换到线上服务器" delegate:self cancelButtonTitle:@"线上" otherButtonTitles:@"确定", nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
self.inputText = [alert textFieldAtIndex:0];
self.inputText.text = @"192.168.";
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [alertView cancelButtonIndex]) {
NSLog(@"线上");
[APPConfig setServerIp:@"线上服务器地址"];
}else {
[APPConfig setServerIp:self.inputText.text];
NSLog(@"确定");
}
}
相关文章推荐
- HTML5 Canvas使用路径——绘制圆形
- ERROR! The server quit without updating PID file!!!(已解决!!!)
- 【转】secureCRT使用退格键(backspace)出现^H解决办法
- js判断浏览器
- python--lambda和def函数
- go语言 获取post方式json
- Android 沉浸式状态栏总结
- C#操作IIS方法集合
- CYC-数据解析1
- SVG 学习(二)--- 创建组合交互式应用
- Android中使用lambda表达式
- WIFI万能钥匙密码查询接口实例
- Android中使用lambda表达式
- android多国语言文件夹文件汇总
- 方法重载和重写(覆盖)的区别
- RemObjects SDK Source For Delphi XE7
- oc的内存管理和@property的属性关键字
- RHEL6.2详细安装greenplum-db-4.3.5.4(part one)
- 二十三种设计模式之结构型模式之代理模式
- JSP使用自定义标签防止表单重复提交的方法