行书书法唐诗三百首:Ipad开发课程-Charpter4 界面化窗口控制 ? 疯狂的老九
来源:百度文库 编辑:九乡新闻网 时间:2024/04/27 20:34:09
Ipad开发课程-Charpter4 界面化窗口控制
22Aug
Posted by: 9 in: Iphone程序开发
在iPad程序中,我们通常用视图来管理窗口的执行过程和内存管理.在View-based Application这个例子中,Xcode将会自动用视图管理器帮助你管理你的窗口.
在前面的章节,你见过MainWindow.xib窗口所包含的视图控制项目.当你双击里面的项目,它将显示一个与项目名称相同的窗口.当你用Xcode创建一个程序的时候,这个程序的窗口控制文件都会由(你的程序的名字)+ViewController来管理和执行.
现在在InterfaceBuilder中双击viewBasedAppViewcontroller.xib文件来编辑它,注意一下,MainWindow.xib文件中的一些项目已经被包含进了viewBaseAppViewController.xib窗口中.在这个例子中里面包含:File's Owner,FirstResponder和View.
你能用右键(或者按住Ctrl点击)File's Owner项目,我们将看到一个属性窗口.可以看到一个view的应用已经被链接到了View项目.
View项目用于在屏幕上显示你的程序窗口内容.双击它,我们可以看到:
当你选择File's Owener项目,我们可以在它的Identity Inspector窗口看到类被指向到了viewBasedAppViewController类,意思就是View窗口正在被viewBasedAppViewController类控制.
viewBasedAppViewController类由两个文件组成:viewBasedAppViewController.h和viewBasedAppViewController.m
viewBasedAppViewController类所在的地方你需要用代码来实现它和你应用程序窗口的连接
链接viewBasedAppViewController.h文件:
#import
#import
@interface viewBasedAppViewController : UIViewController {
}
@end
注意viewBasedAppViewController类是从UIViewController基础类继承的,由它在View窗口中提供大部分的功能
链接viewBasedAppViewController.m文件:
#import “viewBasedAppViewController.h”
@implementation viewBasedAppViewController
/*
// The designated initializer. Override to perform setup that
// is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil
bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// 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];
}
*/
// Override to allow orientations other than the
// default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren’t in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end