我正在尝试使用 Cocos2d 开发应用程序。我无法从 textfield 获得价值。如何使用 Cocos2d 获取文本字段的值(在警报视图中)?
-(void)timed1: (id)sender
{
UIAlertView* dialog = [[[UIAlertView alloc] init] retain];
[dialog setDelegate:self];
[dialog setTitle:@"Enter Time:"];
[dialog setMessage:@" "];
UITextField * nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[dialog addSubview:nameField];
[nameField setBackgroundColor:[UIColor whiteColor]];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 70.0);
[dialog setTransform: moveUp];
[dialog setBackgroundColor:[UIColor clearColor]];
[dialog addButtonWithTitle:@"Done"];
[dialog show];
nameField.clearButtonMode = UITextFieldViewModeWhileEditing;
nameField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
nameField.keyboardAppearance = UIKeyboardAppearanceAlert;
nameField.autocapitalizationType = UITextAutocapitalizationTypeWords;
// timeStatus is a int type global variable
timeStatus =[nameField.text intValue]; // this line not working i can't getting value namefield
[dialog release];
[nameField release];
}