【发布时间】:2012-06-15 15:29:45
【问题描述】:
我发生了一个我无法弄清楚的异常。我这里有这段代码:
newControllers = [[NSMutableArray alloc] initWithCapacity:9]; // Only allocate what we need
// Ok, add the new thumb UIs
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
// Create the view controller
ThumbViewController *newThumbVC = [[ThumbViewController alloc]
initWithNibName:@"NewThumbDisplayView" bundle:nil];
// Set the info
newThumbVC.localInfo = [newInfo objectAtIndex:(i * 3) + j];
// Place it properly
[self.scrollViewContent addSubview:newThumbVC.view];
CGRect rect = CGRectMake(8 + (j * 99), 363 + (i * 134), 106, 142);
newThumbVC.view.frame = rect;
[self.scrollViewContent bringSubviewToFront:newThumbVC.view];
[newControllers addObject:newThumbVC];
}
}
在模拟器上运行时,效果非常好。今天早上我尝试在手机上运行它,但在使用以下堆栈调用 CGRectMake 时出现异常(请注意,输出窗口中根本没有打印任何内容,这让我很难弄清楚)。
线程 1,队列:com.apple.main-thread
#0 0x35220238 in objc_exception_throw ()
#1 0x3751b788 in +[NSException raise:format:arguments:] ()
如果有人能指出这里到底哪里不对,我将不胜感激。
【问题讨论】:
-
你能用常量替换传递给 CGRectMake 的计算值,看看你是否仍然得到异常?为了确定,请尝试使用浮点数而不是整数。
标签: iphone ios nsexception cgrectmake