我希望在設備上的應用程序中,當用戶安裝應用程序時,用戶第一次用戶登錄後,將打開的應用程序和用戶保持登錄應該對他loginScreen有沒有什麼辦法,使這個保存,這樣,如果用戶再次打開應用第二則用戶應登錄陳述和不顯示用戶登錄屏幕感謝。如何請檢查是否應用程序是登錄或沒有第一次
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
self.splitViewController =[[UISplitViewController alloc]init];
self.rootViewController=[[RootViewController alloc]init];
self.detailViewController=[[[FirstDetailViewController alloc]init] autorelease];
self.loginViewController=[[[LoginViewController alloc]init] autorelease];
UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];
if ([detailNav.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
UIImage *image = [UIImage imageNamed:@"Nav.png"];
[detailNav.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
[email protected]"Jamshaid";
[email protected]"NO";
[email protected]"Logout";
self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
self.splitViewController.delegate=self.detailViewController;
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
self.coffeeArray = tempArray;
[tempArray release];
NSMutableArray *tempArray1 = [[NSMutableArray alloc] init];
self.arrayOne = tempArray1;
[tempArray1 release];
NSMutableArray *tempArray2 = [[NSMutableArray alloc] init];
self.arrayTwo = tempArray2;
[tempArray2 release];
NSMutableArray *tempArray3 = [[NSMutableArray alloc] init];
self.libraryArray = tempArray3;
[tempArray3 release];
NSMutableArray *tempArray4 = [[NSMutableArray alloc] init];
self.activityArray = tempArray4;
[tempArray4 release];
NSMutableArray *tempArray5 = [[NSMutableArray alloc] init];
self.arrayOneC = tempArray5;
[tempArray5 release];
NSMutableArray *tempArray6 = [[NSMutableArray alloc] init];
self.arrayTwoC = tempArray6;
[tempArray6 release];
NSMutableArray *tempArrayD = [[NSMutableArray alloc] init];
self.detailArray = tempArrayD;
[tempArrayD release];
NSMutableArray *tempArrayD1 = [[NSMutableArray alloc] init];
self.detailArrayOne = tempArrayD1;
[tempArrayD1 release];
NSMutableArray *tempArrayD2 = [[NSMutableArray alloc] init];
self.detailArrayTwo = tempArrayD2;
[tempArrayD2 release];
NSMutableArray *tempArrayD3 = [[NSMutableArray alloc] init];
self.publishArray = tempArrayD3;
[tempArrayD3 release];
[Coffee getInitialDataToDisplay:[self getDBPath]];
// Add the split view controller's view to the window and display.
// original working [window addSubview:self.splitViewController.view];
[window addSubview:splitViewController.view];
[window makeKeyAndVisible];
return YES;
}
但如何跟蹤記錄,它不應該用戶名稱一次又一次地 –
如果應用程序啓動第一次,這意味着用戶沒有登錄,顯示出他的登錄界面。登錄後保存的用戶名在'NSUserDefault',當用戶在應用程序進入接下來的時間,以便檢查它在應用程序啓動第二次。 – TheTiger
@TheTiger如果應用程序第一次運行,@TheTiger我已經給出我的代碼我將檢查登錄屏幕,然後我可以顯示登錄屏幕,但其他代碼在哪裏作爲碎末 –