0
我正在使用iOS(ObjC)的UIWebView
使用WebView应用程序。该应用程序具有一个登录功能,可以使用className进行分析。登录后UIWebView不显示用户名
根据日志该应用程序正在获取用户名,但它没有加载它,并与卡住你好,登录消息。我正在使用NSUserDefaults
来登录或不登录用户。菜单不会重新加载以显示“欢迎用户名”,因为它应该是。
的代码如下
- (void)viewDidLoad {
[super viewDidLoad];
WIDTH = [UIScreen mainScreen].applicationFrame.size.width;
logoutURL = @"http://XXXXdomain.com/index.php?a=logout&type=app";
preferences = [[NSUserDefaults alloc] init];
NSString *savedSessionId = [preferences objectForKey:@"sessionId"];
islogedin = [preferences objectForKey:@"islogedin"];
userName = @"";
if([preferences objectForKey:@"userName"]){
userName = [preferences objectForKey:@"userName"];
}
if([islogedin isEqualToString:@"true"]){
NSLog(@"arrNavigation=======%@---------%ld", arrNavigation, (long)openSection);
[self reloadMenu];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setName:) name:@"name" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadMenu) name:@"reloadMenu" object:nil];
} else {
NSLog(@"arrNavigation=======%@---------%ld", arrNavigation, (long)openSection);
[self reloadMenu];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLogout:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadMenu) name:@"reloadMenu" object:nil];
}
}
-(void)setName:(NSNotification *)notification{
NSLog(@"logged in & received--------");
NSString *name = [notification object];
NSString *msg = [NSString stringWithFormat:@"Welcome %@", name];
[signinBtn setTitle:msg forState:UIControlStateNormal];
logoutBtn.hidden = NO;
islogedin = @"true";
}
-(void)setLogout:(NSNotification *)notification{
NSLog(@"loggedout--------");
//NSString *name = [notification object];
NSString *msg = [NSString stringWithFormat:@"Hello, Sign In"];
[signinBtn setTitle:msg forState:UIControlStateNormal];
logoutBtn.hidden = YES;
islogedin = @"false";
}