How to loadview

来源:互联网 发布:linux io性能分析 编辑:程序博客网 时间:2024/06/06 04:00
- (void)loadView{// If a nibName was passed to initWithNibName:bundle:...if ([self nibName]) {// Load that nib file, with ourselves as the file's owner, thus connecting// the view outlet to the view in the nib[[NSBundle mainBundle] loadNibNamed:[self nibName] owner:self options:nil];}else {// What is the name of this class?NSString *className = NSStringFromClass([self class]);// What's the full path of the nib file?NSString *nibPath = [[NSBundle mainBundle] pathForResource:classNameofType:@"nib"];// If there really is a nib file at that path, load itif ([[NSFileManager defaultManager] fileExistsAtPath:nibPath]) {[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil];}else {// If there is no nib, just create a blank UIView and set it as the viewUIView *view = [[UIView alloc] initWithFrame:CGRectZero];[self setView:view];[view release];}}}

这个是基本的过程,有助于理解loadview
0 0
原创粉丝点击