2012年11月3日 星期六

[ iOS ] TableView和WebView 的整合

1. 參考 http://cheng-min-i-taiwan.blogspot.tw/2012/10/ios-webview.htmlhttp://cheng-min-i-taiwan.blogspot.tw/2012/11/ios-tableview_2055.html
2. 打開DLIViewController2.xib檔,加入WebView物件。
 3.增加Referencing Outlet。
 4.程式列表


//
//  DLIViewController2.m
//  tableView
//
//  Created by Lin Cheng-Min on 12/11/3.
//  Copyright (c) 2012 Lin Cheng-Min. All rights reserved.
//

#import "DLIViewController2.h"

@interface DLIViewController2 ()

@end

@implementation DLIViewController2
@synthesize webView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

5. 執行結果




沒有留言:

張貼留言