Open a new view when didSelectRowAtIndexPath
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 th开发者_如何学Pythone issue is to do with this line:
[self presentModalViewController:web animated:YES];
Any ideas?
You should present not only a UIWebView
but a UIViewController
with containing UIWebView
. I'm guessing from the described behaviour that you NIB contains only a UIWebView
.
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 a UIWebView
, wire-up the outlets etc., then your code will work as-is.
精彩评论