步骤有三部,
首先要确保在实现页的后缀名字为
.mm
才能实现c++和oc的混编
然后要在.mm文件里面引入一个头文件
#import "EAGLView.h"
最后添加方法如下,但是有一个事情能够还没有解决,在c和oc之下调用当前类的实例指针的方法,是用self,还是用c++的this
还请高人能给出一个答案
UIButton * aButton = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
aButton.frame =CGRectMake(0,0,100, 100);
//[aButton addTarget:self action:@selector(doIt) forControlEvents:UIControlEventTouchUpInside];
EAGLView * view = [EAGLViewsharedEGLView];
[viewaddSubview:aButton];