状態を保存するためにiOS 6 APIを実装しました。動作します。アプリを終了して数ミリ秒間起動した後、リストアされたビューコントローラが起動しますが、コントローラの起動時に表示されます。iOS 6 - 状態の保存と復元
アプリがメインウィンドウのルートビューを起動するたびに設定するので、これは問題である必要があります。私は私の窓のルートビューを設定しています(NSDictionaryの*)launchOptions : - (無効)commonInitializationLaunching
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self commonInitializationLaunching:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self commonInitializationLaunching:launchOptions];
return YES;
}
- (void)commonInitializationLaunching:(NSDictionary *)launchOptions
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
static NSString *const kKeychainItemName = @"OAuthGoogleReader";
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
GTMOAuth2Authentication *auth;
auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
clientID:kClientID
clientSecret:kClientSecret];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
BOOL isSignedIn = [auth canAuthorize];
if (isSignedIn) {
NSLog(@"Signed");
}else{
NSString *scope = @"https://www.google.com/reader/api/";
GTMOAuth2ViewControllerTouch *viewController;
viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:scope
clientID:kClientID
clientSecret:kClientSecret
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[self.navController pushViewController:viewController animated:YES];
// self.window.rootViewController = viewController;
}
});
}
あなたはその中を見ることができます:
は、ここに私のコードです。私はそこに何を入れるべきか分からない。保存された状態が存在するかどうかを確認し、このメソッドをロードしますか?しかしどうですか?
ありがとうございます!私も私のcommonInitializationLaunching
方法から窓コードによって除去 ... willFinishLaunching
に何も
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (!self.isRestored) {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}
[self commonInitializationLaunching:launchOptions];
[self.window makeKeyAndVisible];
return YES;
}
:ここ
は、私はロブのアドバイスを、次の試してみたものです。
私の答えは助けられましたか?いくつかのフィードバックは素晴らしいでしょう。 – rbrown