0
以下工作正常6.1但應用程序崩潰在5.1 ...addSubview崩潰的iOS 5.1但不6.1
weeklyHeaderViewController =[[WeeklyHeaderViewController alloc] init];
[self.view addSubview:weeklyHeaderViewController.view];
這是一個iPad應用程序和所述視圖是含有7的UILabel對939x31的.xib。控制器的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);
}
也許你在weeklyHeaderViewController.xib或其視圖中使用Autolayout – Jack
顯示的錯誤是什麼? – Raptor
iOSBeginner,就是這樣!我一直在預測這件事。謝謝!如果你想得到答案的信用,請繼續並提出你的評論一個答案。 – user278859