我看到了CGRectIntegral
的奇怪行为。这是我的代码:
CGRect rect = CGRectMake(75, 22, 235, 48.000000000000007);
rect = CGRectIntegral(rect);
NSAssert1(rect.size.height == 49, @"I expected 49, but I got: %f!", rect.size.height);
// works on 32 bit iPhone simulator
// throws an exception on iPhone 64 bit simulator & iPhone 5s:
// Terminating app due to uncaught exception 'NSInternalInconsistencyException',
// reason: 'I expected 49, but I got: 48.000000!'
我的猜测是,它与CGFloat在32Bit上是一个浮点数,在64Bit上是一个双重关系 - 并假设在ceil
内使用了CGRectIntegral
。