didSelectRowAtIndexPath 时打开新视图
在我的主视图中,我有一个 UITableView。我想在用户点击单元格时打开一个新视图,这就是我当前所拥有的:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
WebViewController *web = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
web.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:web animated:YES];
[web release];
}
问题是,Web 视图在表视图“内”打开。该表非常小(320x160px),因此新的 Web 视图仅在此框架内打开。我需要它完全/全屏打开。
我猜问题与此行有关:
[self presentModalViewController:web animated:YES];
有什么想法吗?
In my main view I have a UITableView. I want to open a new view when the user taps on a cell, this is what I have currently:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
WebViewController *web = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
web.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:web animated:YES];
[web release];
}
Problem is, the web view opens 'within' the table view. The table is quite small (320x160px) and so the new web view is only opened within this frame. I need it to open fully/full screen.
I'm guessing the issue is to do with this line:
[self presentModalViewController:web animated:YES];
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不仅应该呈现一个
UIWebView
,还应该呈现一个包含UIWebView
的UIViewController
。我从所描述的行为中猜测您的 NIB 仅包含一个UIWebView
。通常,视图控制器子类将包含导航栏或工具栏,以便可以关闭视图。
有几种方法,但一种是向您的 NIB 添加一个 UIViewController,然后拖入一个 UIWebView,连接插座等,然后您的代码将按原样工作。
You should present not only a
UIWebView
but aUIViewController
with containingUIWebView
. I'm guessing from the described behaviour that you NIB contains only aUIWebView
.Typically the view controller subclass will include a navigation bar or toolbar so the view can be dismissed.
There a several approaches, but one would be to add a
UIViewController
to your NIB, then drag-in aUIWebView
, wire-up the outlets etc., then your code will work as-is.