提高iOS开发效率的小技巧与思路

2020-01-15 16:13:42王冬梅

ios开发小技巧,ios开发思路

4.这个通知发送到了UITabBarController,进行让用户重新登录处理


#import <UIKit/UIKit.h>

@interface WXMainController : UITabBarController

@end

#pragma mark -监听账号互踢,这时候先退出登录,然后回到首页
- (void)addNotification{

  WS(weakSelf);

  //  [[NSNotificationCenter defaultCenter] postNotificationName:KMutualKickNotification object:nil];
  [[NSNotificationCenter defaultCenter] addObserverForName:KMutualKickNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {

    [weakSelf alertWindow];

  }];

}

#pragma mark-弹出框选择界面
- (void)alertWindow{


  if (!self.isShow) {

    self.isShow = YES;

    UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"" message:@"您的账号已在其他设备登录,现在您已经处于退出登录状态" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];

    [alter show];
  }


}

#pragma mark-弹出框选择界面的代理方法,点击确定就弹出登录框
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

  if (buttonIndex == 0) {

    WXLoginController * loginController = [WXLoginController showLoginContoller:NO andIsShowColse:NO];

    [self presentViewController:loginController animated:YES completion:nil];

    self.isShow = NO;

  }

}

任何事情都有方法和技巧,单没有捷径,IOS开发也不例外,脚踏实地从实践中发现方法,熟练后就有技巧。希望本文能够帮助的学习IOS开发的大家。


注:相关教程知识阅读请移步到IOS开发频道。