如果用户输入正确的代码,我会尝试将用户定向到新的场景,但它不起作用。这是代码:
- (void)showCodes:(id)sender {
alert = [[UIAlertView alloc] initWithTitle:@"Codes" message:@"Enter a code." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Enter", nil];
code = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0, 60);
[alert setTransform:myTransform];
[code setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:code];
[alert show];
[code retain];
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSString *text = code.text;
NSString *othermode;
bernierMode = @"epicmode";
if (text == nil) {
//nothing
}
else if(text == othermode)
{
//go to other view...
}
else {
}
}
}
我在头文件中使用cocos2D(不要认为有所作为),我还设置了UIAlertView Delegate。
谢谢,
泰特