可以通过滑动来关闭模态视图

发布于 2024-09-14 08:26:30 字数 1099 浏览 4 评论 0原文

在展示我的模态视图时,我遇到了奇怪的行为。我有一个滚动视图作为我的主视图,有 4 页...点击滚动视图上的按钮会显示模态视图,但我可以通过向左或向右滑动来关闭模态视图。显然我只是希望能够使用“完成”按钮来关闭。

这是我用来显示模态视图的方法:

- (void)popUpModal:(id)sender {

UIViewController *detailView = [[UIViewController alloc] initWithNibName:@"KeyboardView" bundle:nil];
detailView.view.backgroundColor = [UIColor blackColor];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:detailView];

UIBarButtonItem * doneButton =
[[UIBarButtonItem alloc]
 initWithBarButtonSystemItem:UIBarButtonSystemItemDone
 target:self action:@selector(doneAction) ];

detailView.navigationItem.rightBarButtonItem = doneButton;

[doneButton release];


UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];

NSString *url = @"http://www.google.com";

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];


[detailView.view addSubview:webView];

[self presentModalViewController:navController animated:YES];

[detailView release];

[navController release];

}

什么会导致这种行为?

谢谢。

I have encountered a strange behaviour when presenting my modal view. I have a scroll view on as my main view with 4 pages... tapping on a button on the scroll view presents the modal view, but i can dismiss the modal view by swiping left or right. Obviously i just want to be able to dismiss using the Done button.

This is the method i use to display the modal view:

- (void)popUpModal:(id)sender {

UIViewController *detailView = [[UIViewController alloc] initWithNibName:@"KeyboardView" bundle:nil];
detailView.view.backgroundColor = [UIColor blackColor];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:detailView];

UIBarButtonItem * doneButton =
[[UIBarButtonItem alloc]
 initWithBarButtonSystemItem:UIBarButtonSystemItemDone
 target:self action:@selector(doneAction) ];

detailView.navigationItem.rightBarButtonItem = doneButton;

[doneButton release];


UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];

NSString *url = @"http://www.google.com";

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];


[detailView.view addSubview:webView];

[self presentModalViewController:navController animated:YES];

[detailView release];

[navController release];

}

What would cause this behaviour?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文