gpt4 book ai didi

ios - iPad模态表单 View 不

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:34:03 26 4
gpt4 key购买 nike

我在 didSelectRowAtIndex 中使用此代码。在我的 iPhone 上它推送一个 View ,在 iPad 上我希望它在一个小的弹出窗口中呈现一个 View 模态。出于某种原因,在我的 iPad 上它以模态方式呈现,但它仍然是全屏而不是一个小的模态弹出窗口。所以 if 语句是有效的,我使用类似的东西在别处呈现导航 Controller 并且它工作正常。

有什么想法吗?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (NSClassFromString(@"UISplitViewController") != nil && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
self.navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
self.navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentModalViewController:detailViewController animated:YES];
[detailViewController release];
}
else
{
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
}

最佳答案

您在错误的对象上设置了 modalTransitionStyle 和 modalPresentationStyle。您应该将它们都设置在 detailViewController 而不是 self.navigationController 上。

编辑:这里是完整的代码以及导航栏,完成按钮将关闭模态视图:

DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
navController.modalPresentationStyle = UIModalPresentationFormSheet;

UIBarButtonItem *doneBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(modalViewDone)];
detailViewController.navigationItem.rightBarButtonItem = doneBarButton;
detailViewController.navigationItem.title = @"Details";
[doneBarButton release];

[self.navigationController presentModalViewController:navController animated:YES];
[detailViewController release];
[navController release];

你需要实现这个方法:

- (void)modalViewDone
{
[self.navigationController dismissModalViewControllerAnimated:YES];
}

关于ios - iPad模态表单 View 不,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6951485/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com