iOS - 加入 Webview ,超簡單!

1. 先在UIViewController 加UIWebViewDelegate , 再加入webview 物件!

螢幕快照 2016-08-31 上午10.38.45.png

2. 在webviewController 加入loadview,在最開始時就會使用。把webview 都加進去。 viewDidLoad 內加入loadRequest, 把需要顯示的網頁load 出來。

螢幕快照 2016-08-31 上午10.39.04.png

同場加影:

ViewDidLoad 跟 LoadView 的分別:

ViewDidLoad is called when your view loading is finished and loadView is called when loading starts。

loadView 是用於沒有做用nib 的時候,當一開始loading 的時候就開始了,而ViewDidLoad就是在有nib,跟nib 已經加載完成後才開始。

 

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/
arrow
arrow

    lionlionchopper 發表在 痞客邦 留言(0) 人氣()