UIView animateWithDuration:动画:完成:块不在.mm文件中编译

时间:2012-08-09 08:40:56

标签: c++ objective-c ios xcode4

我在.mm文件中有以下代码:

[UIView animateWithDuration:0.3 animations:^{
    self.titleLabel.alpha = 0.0;
} completion:^(BOOL finished) {    //<<compiler complains here
    self.titleLabel.alpha = 1.0;
}];

但是我收到了编译错误:

  

无法使用类型为'void(^)(int)'的右值初始化'void(^)(BOOL)'类型的参数

在上面提到的那一行。代码在普通的.m文件中正常。我做错了什么,或者编译器有问题吗?

更新:标头导入为:

#import <UIKit/UIKit.h>

和.mm导入是(审查):

#import "XXSelectViewController.h"
#import "XXViewController.h"
#import "AboutViewController.h"
#import "HighScoresViewController.h"
#import "GameModel.h"

更新2:此外,我在此行收到警告:

- (void)viewDidDisappear:(BOOL)animated

警告:

  

“viewDidDisappear:”实现中的冲突参数类型:'BOOL'(又名'signed char')vs'int'

我们在这个项目中使用PowerVR工具,在PVRShell.h和PVRTResourceFile.h中有以下几行:

typedef bool (*PFNReleaseFileFunc)(void* handle);

typedef bool (*PFNReleaseFileFunc)(void* handle);

我不知道这是否与这些问题有关......

1 个答案:

答案 0 :(得分:2)

事实证明错误的原因是因为这条线深埋在PVR工具中:

#define BOOL int

因此,有一个宏会浏览所有代码,将BOOL替换为int。不太理想!我认为它导致问题的原因是因为工具被添加为文件夹而不是嵌入式.xcodeproj ......所以我们可能需要重新导入它。经验教训!

奇怪的是,如果我注释掉那一行,那么代码仍然有用;)但谁知道多久了!