我正在努力提供用戶在繼續訪問應用程序之前必須接受的YES/NO屏幕。當我停止從XCode啓動時行爲發生變化
這個'接受或拒絕'方法從ApplicationDidFinishLaunching內部觸發,並且在一個定時器上以2秒(或任何時間)觸發。它在NSUserDefaults中查找並檢索一個密鑰,告訴我該協議是否已被接受。如果沒有(或無),我啓動一個modalViewController來提交協議。該AppDidFinishLaunching方法實際上是樣板,看起來像這樣:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the tab bar controller's view to the window and display.
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
[self performSelector:@selector(checkTheEULA) withObject:nil afterDelay:kDelay];
return YES;
}
一切都很正常。問題是,它只能工作一次 - 當我從Xcode啓動時。如果我停止該應用並從模擬器或我的設備上啓動,則不會向用戶呈現模態視圖。
有誰能告訴我發生了什麼事情嗎?我假設它與appDelegate本身有關係?我是否留下了一些東西?
任何幫助將是非常讚賞 - 我還是挺綠:-)
感謝,
- (void)checkTheEULA{
// get value in kAcceptedOrNot key (NSString, either YES NO or nil), assign it to acceptedOrNot
self.acceptedOrNot = [[NSUserDefaults standardUserDefaults] objectForKey:kAcceptedOrNotKey];
if (self.acceptedOrNot == nil || [self.acceptedOrNot isEqualToString:@"NO"]) {
NSLog(@"The value of kAcceptedOrNot is %@ (nil or NO). This means that the EULA has never been launched, or has launched but has been UNaccepted", self.acceptedOrNot);
NSLog(@"I'm launching the ModalView to give the user the chance to accept the EULA");
[self showModalView];
} else {
// else, the value of kAcceptedOrNot exists and is YES, and so no action needs to be taken
NSLog(@"Value of accepteOrNot is %@. (hopefully it's 'YES' :-)", acceptedOrNot);
}
}
你可以發佈你的`checkTheEULA`代碼? – 2010-12-08 04:44:53
當然。今晚會這樣做。謝謝! – 2010-12-08 14:29:56