@@ -56,9 +56,6 @@ - (void)viewDidLoad
5656 self.myTableView .tableHeaderView = [self customHeaderView ];
5757
5858 [self addChangeBaseURLGesture ];
59- if ([NSObject baseURLStrIsTest ]) {
60- kTipAlert (@" 在此页面连续点击屏幕 10 下切换到生产环境!" );
61- }
6259}
6360
6461- (void )viewWillDisappear : (BOOL )animated {
@@ -71,27 +68,32 @@ - (void)addChangeBaseURLGesture{
7168 UITapGestureRecognizer *tapGR = [UITapGestureRecognizer bk_recognizerWithHandler: ^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
7269 @strongify (self);
7370 if (state == UIGestureRecognizerStateRecognized) {
74- [self changeToTest: ![ NSObject baseURLStrIsTest ] ];
71+ [self changeBaseURLTip ];
7572 }
7673 }];
7774 tapGR.numberOfTapsRequired = 10.0 ;
7875 [self .view addGestureRecognizer: tapGR];
7976}
8077
81- - (void )changeToTest : (BOOL )isTest {
82- [NSObject changeBaseURLStrToTest: isTest];
83- NSString *tipstr;
84- if (isTest) {
85- tipstr = @" 你现在切换到了测试环境。\n 若要重新切换回生产环境则需要按照如下步骤操作:\n \
86- 1. 进到 '登录' 页\n \
87- 2. 点击 '无法登陆' 按钮\n \
88- 3. 进入 '忘记密码?/未设置密码?' 页面\n \
89- 4. 单击屏幕 10 次" ;
90- }else {
91- tipstr = @" 你已成功切换到了生产环境!" ;
78+ - (void )changeBaseURLTip {
79+ if ([UIDevice currentDevice ].systemVersion .integerValue < 8 ) {
80+ [NSObject showHudTipStr: @" 需要 8.0 以上系统才能切换服务器地址" ];
81+ return ;
9282 }
93- kTipAlert (@" %@ " , tipstr);
94- [self .navigationController popToRootViewControllerAnimated: YES ];
83+ UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle: @" 更改服务器 URL" message: @" 空白值可切换回生产环境\n (地址末尾务必加上「/」)" preferredStyle: UIAlertControllerStyleAlert];
84+
85+ UIAlertAction *cancelA = [UIAlertAction actionWithTitle: @" 取消" style: UIAlertActionStyleCancel handler: nil ];
86+ UIAlertAction *confirmA = [UIAlertAction actionWithTitle: @" 确定" style: UIAlertActionStyleDestructive handler: ^(UIAlertAction * _Nonnull action) {
87+ [NSObject changeBaseURLStrTo: alertCtrl.textFields[0 ].text];
88+ }];
89+ [alertCtrl addTextFieldWithConfigurationHandler: ^(UITextField * _Nonnull textField) {
90+ textField.placeholder = @" Coding 服务器地址" ;
91+ textField.text = [NSObject baseURLStr ];
92+ }];
93+ [alertCtrl addAction: cancelA];
94+ [alertCtrl addAction: confirmA];
95+ [self presentViewController: alertCtrl animated: YES completion: nil ];
96+
9597}
9698
9799- (void )viewWillAppear : (BOOL )animated {
0 commit comments