Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 尝试从视图控制器中退出_Ios_Objective C - Fatal编程技术网

Ios 尝试从视图控制器中退出

Ios 尝试从视图控制器中退出,ios,objective-c,Ios,Objective C,我有一个二等舱,在头等舱 - (IBAction)Login:(id)sender { SampleViewController2 *sampleView = [[[SampleViewController2 alloc] init]; [self presentModalViewController:sampleView animated:YES]; } 二等舱 - (IBAction)Logout:(id)sender { [self dismissModalViewContr

我有一个二等舱,在头等舱

- (IBAction)Login:(id)sender {
 SampleViewController2 *sampleView = [[[SampleViewController2 alloc] init];
   [self presentModalViewController:sampleView animated:YES];
}
二等舱

- (IBAction)Logout:(id)sender {
  [self dismissModalViewControllerAnimated:YES];
}

它表示警告试图从视图控制器中解除。。这里有什么问题。

如果当前视图的模式视图是否被取消,您可以在取消之前检查它

if (![[self modalViewController] isBeingDismissed]){
        [self dismissModalViewControllerAnimated:YES];
}

如果当前视图的模式视图是否被取消,您可以在取消之前检查它

if (![[self modalViewController] isBeingDismissed]){
        [self dismissModalViewControllerAnimated:YES];
}
添加以下内容:

 if (![[self modalViewController] isBeingDismissed])
        [self dismissModalViewControllerAnimated:YES];
做一个简单的谷歌搜索,你说的问题很常见…

添加以下内容:

 if (![[self modalViewController] isBeingDismissed])
        [self dismissModalViewControllerAnimated:YES];

做一个简单的谷歌搜索,你说的问题很常见…

为什么这些动作是从不同的类触发的?您可能只有一个类--
UIViewController
的子类--它负责显示和隐藏
SampleViewController2
。发布您收到的实际警告。在演示或解除过程中,尝试从视图控制器中解除!看起来这是从iOS6开始的,据我所知,我不认为这发生在5.1中。为什么这些动作是从不同的类触发的?您可能只有一个类--
UIViewController
的子类--它负责显示和隐藏
SampleViewController2
。发布您收到的实际警告。在演示或解除过程中,尝试从视图控制器中解除!看起来这是从iOS6开始的,据我所知,我不认为这发生在5.1中。