Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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
Iphone 奇怪的行为ModalViewController_Iphone_Objective C_Ios_Ipad_Modalviewcontroller - Fatal编程技术网

Iphone 奇怪的行为ModalViewController

Iphone 奇怪的行为ModalViewController,iphone,objective-c,ios,ipad,modalviewcontroller,Iphone,Objective C,Ios,Ipad,Modalviewcontroller,我有一个视图控制器AddCommentViewController,它可以脱机保存注释,并在脱机保存时编辑注释 在要添加新注释并将其脱机保存的视图中加载AddCommentViewController时,没有问题: AddCommentViewController *addView = [AddCommentViewController new]; [addView setTitle:@"New Comment"]; UINavigationController *navController

我有一个视图控制器AddCommentViewController,它可以脱机保存注释,并在脱机保存时编辑注释

在要添加新注释并将其脱机保存的视图中加载AddCommentViewController时,没有问题:

AddCommentViewController *addView = [AddCommentViewController new];

[addView setTitle:@"New Comment"];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addView];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];

[delegate.navigationController presentModalViewController:navController animated:YES];
[delegate dismissPopOver:self animated:YES];
[navController release];
[addView release];
这里没问题,视图从底部很好地设置了动画。当它被忽略时,它会被很好地动画化到底部

但现在问题来了

在另一个视图中,我可以看到脱机保存的所有注释的列表。当我在这里加载AddCommentViewController时,奇怪的事情发生了

当我尝试呈现视图模式时,它从左侧设置动画,在一个奇怪的位置停止,不是居中,而是在按钮右侧。当我关闭它时,视图被设置为动画回到左侧,而我的另一个视图被设置为纵向。 我似乎找不到问题,代码几乎相同:

Comment *comment = [allComments objectAtIndex:indexPath.row];

AddCommentViewController *addView = [[AddCommentViewController alloc] initWithId:comment.identifier];

[addView setTitle:@"Change comment"];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addView];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
navController.navigationBar.tintColor = [UIColor P4aPurple];

[self presentModalViewController:navController animated:YES];

[navController release];
[addView release];
我试图通过以下方式将视图强制设置为特定方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
但我得到了这个错误:

The view controller <UISplitViewController: 0x1843d0> returned NO from -shouldAutorotateToInterfaceOrientation: for all interface orientations. It should support at least one orientation.

如果我在加载脱机设备时将设备保持纵向,则表明其工作正常。

如果要强制纵向,请尝试以下操作:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
        return YES;
    else return NO;
}

修正后,视图必须在拆分视图控制器中显示,而不是在拆分视图的局部视图控制器中显示