【发布时间】:2012-10-05 07:14:04
【问题描述】:
我想在Cocos2d中使用UITextField,所以写了如下代码:
// In HelloWorldLayer...
-(id) init
{
if( self=[super init] )
{
CGSize winSize = [[CCDirector sharedDirector] winSize];
UIView *view = [[CCDirector sharedDirector] openGLView];
// CGRect rect = CGRectMake(60.0, 45.0, 360.0, 25.0);
CGPoint pos1 = ccp( 60.0, winSize.height - 45.0 );
CGPoint pos2 = ccp( 360.0, 25.0 );
pos1 = [[CCDirector sharedDirector] convertToUI:pos1];
pos2 = [[CCDirector sharedDirector] convertToUI:pos2];
// UITextField *_tField; it is declared in field
_tField = [[UITextField alloc] initWithFrame:CGRectMake(pos1.x, pos1.y, pos2.x, pos2.y)];
_tField.backgroundColor = [UIColor whiteColor];
_tField.borderStyle = UITextBorderStyleRoundedRect;
_tField.returnKeyType = UIReturnKeyDone;
_tField.delegate = self;
[view addSubview:_tField];
}
return self;
}
我该如何解决这个问题...?
【问题讨论】:
-
请添加您的错误信息——不要仅仅添加一个链接,因为它们已经过时了。
-
但是我的代码能够很好地编译...错误消息是否意味着问题,而不仅仅是编译错误?然后我明白了。 (对不起,我英语不好..)
标签: cocos2d-iphone uitextfield