0

解決できない問題があります。ログインページで、共有インスタンスを作成してロードしています:

ViewController *vc = [ViewController sharedInstance];

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.1) {
    [self presentViewController:vc animated:YES completion:nil];
}else{
    [self presentModalViewController:vc animated:YES];
}

これは初めてうまく機能します。私のView Controllerには、次のようなログオフメソッドがあります。

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.1) {
    [self dismissViewControllerAnimated:NO completion:nil];       
}else{
    [self dismissModalViewControllerAnimated:NO];
}

それもうまく機能しますが、ログオフしてから再度ログインしようとすると、コードの途中で停止します...エラーも言い訳もありません。

誰でも解決策を知っていますか?

ありがとう

編集:方法sharedInstance

static ViewController *vcontroller; 
+ (ViewController *) sharedInstance { 
    if (!vcontroller) { 
        vcontroller = [[ViewController alloc] init]; 
    } return vcontroller; 
} 
4

1 に答える 1

0

From your explanation I thing U really want (should) to remove the shared instance. So make sure you have a method for setting the cController static variable to nil in you code. I dont think calling sharedInstance and setting that will work since it seems like you are using singleton and if you have the proper implementation of singleton pattern it will not work. Also you may be able to clear this variable right be lore login to based on your requirements

于 2013-01-16T14:45:30.860 に答える