小编Tig*_*ing的帖子

返回内联函数的类型

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)

c c++ iphone objective-c cocos2d-iphone

1
推荐指数
1
解决办法
319
查看次数

1
推荐指数
1
解决办法
296
查看次数

无法获得支持的接口方向数组,为什么?

在这段代码中:

   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中运行.

iphone ipad uiinterfaceorientation ios

1
推荐指数
1
解决办法
2436
查看次数

为什么这个CGRectContainsPoint会失败?

我想我不完全理解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)

当我绘制它时,该点位于矩形内部.但它返回"不起作用".

iphone objective-c ios

0
推荐指数
1
解决办法
1342
查看次数