0


我正在为 iPhone 使用新的FBConnect。但是我已经按照给定的步骤操作了。但是当我构建它时,它会向我显示这个警告“警告:'UIDevice'可能不会响应'-isMultitaskingSupported'”并且应用程序崩溃。我正在使用 iphone 模拟器 4.1,但它仍然向我显示此警告。如果有人可以帮助我解决这个问题,那就太好了。

提前致谢。

4

2 回答 2

4

iOS 4.0 之前的版本没有这个方法,所以respondsToSelector在调用它之前你必须先检查该方法是否存在。

if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [[UIDevice currentDevice] isMultitaskingSupported]) {
    // Device supports multi-tasking...

}
else {
    // No such luck.
}

因此,当您使用 iPhone 模拟器 4.1 时,我猜您已将 iOS 版本设置为 3.2(使用硬件菜单上的版本选项来更改此设置)。

于 2011-03-20T21:40:32.217 回答
0

您可以在您的项目中添加下面提到的方法以在任何操作之前检查设备是否支持多线程

- (BOOL) isMultitaskingSupported
{
    BOOL result = NO;
    UIDevice *device = [UIDevice currentDevice];

    if (device != nil)
    { 
        if ([device respondsToSelector:@selector(isMultitaskingSupported)] == YES)
        { 
            #ifdef __IPHONE_4_0 
                #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0)
                    result = [device isMultitaskingSupported]; 
                #endif
            #endif
        } 
        return(result);
    }
}

如果设备支持多任务处理,这将返回 Bool 即 True

于 2011-08-05T06:52:43.223 回答