2017-06-21 2 views
0

ユーザーがホームページにログインし、セグが接続されていて、識別子が「loggedin」の場合、segueを実際に実行しようとしています 現在ログアウトのためにコーディングされているので、NSUserDefaultsをクリアする方法はなく、私もそれが私の価値を取り戻すことを確認しました!ログインしたユーザーがNSUserDefaultsを使用しているユーザーデータを処理していません

以下

が私の見解は、この最初のビューコントローラの負荷方法をやっている私は、これは私のストーリーボードで、ログにuがエラーに this is my screenshot

を見ることができるOTP

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 
    self.custid =[defaults objectForKey:@"uid"]; 
    NSLog(@"Customer id--%@",self.custid); 
    if(self.custid!=nil) 
    { 
     [self performSegueWithIdentifier:@"loggedin" sender:self]; 
    } 

    [_checkboxb setBackgroundImage:[UIImage imageNamed:@"unsigned checkbox"] 
         forState:UIControlStateNormal]; 
    [_checkboxb setBackgroundImage:[UIImage imageNamed:@"signed check box"] 
         forState:UIControlStateSelected]; 
    UIGraphicsBeginImageContext(self.view.frame.size); 
} 

のために、ユーザからの携帯電話番号を取得しています

とそのビューコントローラの私のコードが実行されている最初のビューが実行されているが、ビューは最初のビューコントローラのビューです

+0

最初のビューコントローラでユーザーのログインステータスを確認しないでください。 appdelegateでログインステータスを確認し、それに従ってroot view controllerをassizeします。 –

+0

@RajeshkumarRどこで私はルートビューコントローラを使用することをお勧めしますか? – Akshay

+0

AppDelegateの 'didFinishLaunchingWithOptions'メソッド –

答えて

1

最初のビューコントローラではユーザーのログインステータスをチェックしません。ログイン状況をAppDelegateで確認し、それに従ってルートビューコントローラを割り当てます。

@implementation AppDelegate 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; 
    UIViewController *viewController; 
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 
    if([defaults objectForKey:@"uid"]!=nil) 
    { 
    viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"]; 
    } 
    else 
    { 
    viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController1"]; 
    } 
    self.window.rootViewController = viewController;//With out NavigationController 
    //self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:viewController];//With NavigationController 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 
+0

は、その識別子segueの識別子ですか?またはコントローラIDを表示しますか?それはvcのstoryboard idですか? – Akshay

+0

@Akshay No. viewcontrollerの識別子 –

+0

です。ログアウトして、segueをotp viewに実行する方法は? – Akshay

関連する問題