DAY thirteen – My Google
今天来建立一个 iPhone app 软件,用你的iPhone 直接打开谷歌网页。
纲要:
- 在程序显示前运行代码 -
- 关于iPhone的“UIWebView” 运用 -
首先运行以安装好的 xCode
选择: File->New Project.
从 "New Project" 窗口
选择 : iPhone OS ->Applications-> Utility Application
命名 : 我这里命名为 “Mygoogle”
(1)
@interface MainViewController : UIViewController {
}
@end
(2)
#import "MainViewController.h"
#import "MainView.h"
@implementation MainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterf
}
- (void)didReceiveMemoryWarning {
}
- (void)dealloc {
}
(3)
#import <UIKit/UIKit.h>
@interface FlipsideViewController : UIViewController {
}
@end
(4)
#import "FlipsideViewController.h"
@implementation FlipsideViewController
- (void)viewDidLoad {
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterf
}
- (void)didReceiveMemoryWarning {
}
- (void)dealloc {
}
@end
(5) 导入下面html文件
下载下面html,放入 Mygoogle 文件夹内并命名为下面名称about.html
文件: about.html
在xCode下右键点击 Mygoogle->Add->Existing Files; 在 Mygoogle 文件夹内,选择下载好的图片,按 Add
(6) MainView 界面设置
双击文件: "mainView.xib" ;
然后 "Interface Builder"
(7) 加入 UIWebView ; 显示:www.google.com
选择: Tools -> Library ; 从Library显示菜单中拖拉一个 Webview 到 Main View
在主视窗口或文件窗口;点击 UIWebView
选择: Tools -> Connection Inspector
移动鼠标在"New Referencing Outlets" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner";
放开鼠标选择键出现 "webView"; 选上它。
(8) FlipsideView 界面设置
双击文件: "mainView.xib" ;
然后 "Interface Builder"
(9) 加入 UIWebView ; 显示:about.html
选择: Tools -> Library ; 从Library显示菜单中拖拉一个 Webview 到 Main View
在主视窗口或文件窗口;点击 UIWebView
选择: Tools -> Connection Inspector
移动鼠标在"New Referencing Outlets" 后面圆圈上; 圆圈变为(+); 拖向直线连接到"File's Owner";
放开鼠标选择键出现 "webView"; 选上它。
最后在 xCode 选择 Build->Build and Go; Save All.
下载今天教程文件: Mygoogle.zip