cocos2d를 사용하여 경고보기로 텍스트 필드의 값을 어떻게 얻을 수 있습니까?
-
03-07-2019 - |
문제
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];
}
해결책
액션 시트와 경고는 비동기 적으로 처리됩니다. 귀하의 경우, 메시지 [대화 상자 쇼]는 나중에 실행을위한 쇼 이벤트를 예약합니다 (메인 런 루프가 처리). 몇 개의 nslog () s를 넣으면 [show] 메시지가 거의 즉시 반환되는 것을 알 수 있습니다. .
입력이 포함 된 차단, 모달 대화 상자를 원합니다. 액션 시트와 알림은 예/아니오/취소 버튼 푸시를 넘어서 사용자 입력을 위해 설계되지 않았습니다. 당신은 자신의 견해를 요리해야합니다. 너무 어렵지는 않지만 액션 시트/경고를 사용하는 것보다 더 많은 작업이 필요합니다.
제휴하지 않습니다 StackOverflow