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";
}