Cocos2d中的这个方法:
/** Returns opposite of point.
@return CGPoint
@since v0.7.2
*/
static inline CGPoint
ccpNeg(const CGPoint v)
{
return ccp(-v.x, -v.y);
}
Run Code Online (Sandbox Code Playgroud)
内联后为什么会说'CGPoint'?为什么不
static inline ccpNeg(...
Run Code Online (Sandbox Code Playgroud)
?
UIButton有3种不同的图像属性:
currentBackgroundImage currentImage imageView
他们每个人代表什么?
在这段代码中:
NSArray *supportedOrientations = nil;
if( iPhone ) { // bool
supportedOrientations = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
// one array element
}
else if( iPad ) { // bool
supportedOrientations = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations~ipad"];
// returns nil
}
else {
NSLog(@"%@:%@ device type not identified", kClassName, kMethodName);
}
Run Code Online (Sandbox Code Playgroud)
如果设备是iPhone,则supportedOrientations具有该阵列.
如果是iPad,supportOrientations为零.
始终找到该文件,因此NSLog永远不会显示(通过调试器逐步确认).
使用文本编辑检查plist时,我看到:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
Run Code Online (Sandbox Code Playgroud)
有关为什么会发生这种情况的任何想法?
在iOS模拟器版本4.3中运行.
我想我不完全理解containsPoint方法:
// test
CGRect compareRect = CGRectMake(-39, -62, 39, 62);
CGPoint comparePoint = CGPointMake(3, -27);
if( CGRectContainsPoint(compareRect, comparePoint) ) NSLog(@"works");
else NSLog(@"doesn't work");
Run Code Online (Sandbox Code Playgroud)
当我绘制它时,该点位于矩形内部.但它返回"不起作用".