判断当前的页面是否登录,如果登录直接显示数据,如果没有登录,就先登录(使用单力判断)
1.在单例.h中写@property(nonatomic,assign)BOOL isLogin;
+(instancetype)sharePerson;
2.在.m中写+(instancetype)sharePerson{
static id _instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instance = [[self alloc]init];
});
return _instance;
}
3.在APPdelegate中 WXFPPerson *person = [WXFPPerson sharePerson];
person.isLogin = isLogin;
保存登录状态
4.在进入该页面时判断 if(_person.isLogin)
{
VillageViewController *village = [[VillageViewController alloc] init];
[self.navigationController pushViewController:village animated:YES];
}else
{
LoginViewController *vc = [[LoginViewController alloc]init];
self.view.window.rootViewController = vc;
}
网友评论