2011/11/10

DetailViewControllerにwebViewの追加

選択したセルのリンク先を遷移先のdetailViewControllerのwebViewに表示
detailViewController.hにUIWebViewの変数宣言とIBOutletを忘れずに

@implementation MasterViewController

- (void) tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DetailViewController *detailVC = 
    [self.storyboard instantiateViewControllerWithIdentifier:@"Detail"];
    
    CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
    UIWebView *uiWebView = [[UIWebView alloc] initWithFrame:webFrame];
    uiWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
    uiWebView.scalesPageToFit = YES;
    [uiWebView loadRequest:[NSURLRequest requestWithURL:
                            [NSURL URLWithString:[linkArray objectAtIndex:indexPath.row]]]];

    [detailVC.view addSubview:uiWebView];
    [self.navigationController pushViewController:detailVC animated:YES];
//safariでweb表示
//    [[UIApplication sharedApplication]
//    openURL:[NSURL URLWithString:[linkArray objectAtIndex:indexPath.row]]];

}