以下在 6.1 中工作正常,但应用程序在 5.1 中崩溃...
weeklyHeaderViewController =[[WeeklyHeaderViewController alloc] init];
[self.view addSubview:weeklyHeaderViewController.view];
这是一个 iPad 应用程序,视图为 939x31 .xib,包含 7 个 UILabel 对。控制器的 viewDidLoad 方法在 7 对之间插入一个 4x30 图像分隔符,然后将视图移动到屏幕底部的位置。
我可以通过 initWithNibName 对其进行跟踪,因此它似乎分配得很好。它在 addSubview 处崩溃并且永远不会到达 viewDidLoad 方法。
关于 5.1,我应该在这里缺少什么东西吗?
任何建议,将不胜感激。
谢谢,
约翰
// WeeklyHeaderViewController.m
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
CGRect myImageRect = CGRectMake(131, 0, 4, 30);
UIImageView *image = [[UIImageView alloc] initWithFrame:myImageRect];
[image setImage:[UIImage imageNamed:@"weeklyDaySeparator.png"]];
[self.view addSubview:image];
[image release];
myImageRect = CGRectMake(266, 0, 4, 30);
image = [[UIImageView alloc] initWithFrame:myImageRect];
[image setImage:[UIImage imageNamed:@"weeklyDaySeparator.png"]];
self.view addSubview:image];
[image release];
myImageRect = CGRectMake(400, 0, 4, 30);
image = [[UIImageView alloc] initWithFrame:myImageRect];
[image setImage:[UIImage imageNamed:@"weeklyDaySeparator.png"]];
[self.view addSubview:image];
[image release];
myImageRect = CGRectMake(535, 0, 4, 30);
image = [[UIImageView alloc] initWithFrame:myImageRect];
[image setImage:[UIImage imageNamed:@"weeklyDaySeparator.png"]];
[self.view addSubview:image];
[image release];
myImageRect = CGRectMake(670, 0, 4, 30);
image = [[UIImageView alloc] initWithFrame:myImageRect];
[image setImage:[UIImage imageNamed:@"weeklyDaySeparator.png"]];
[self.view addSubview:image];
[image release];
myImageRect = CGRectMake(804, 0, 4, 30);
image = [[UIImageView alloc] initWithFrame:myImageRect];
[image setImage:[UIImage imageNamed:@"weeklyDaySeparator.png"]];
[self.view addSubview:image];
[image release];
self.view.frame = CGRectMake(74, 687-14, self.view.frame.size.width, self.view.frame.size.height);
}