UIAlertView and UITextFields not working
I am trying to direct the user to a new scene if he enters a correct code, but it does not work. Here is the code:
- (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:myTransf开发者_JAVA技巧orm];
[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 {
}
}
}
I am using cocos2D (don't think that makes a difference) in my header file, I also set the UIAlertView Delegate.
Thanks,
Tate
Gaming - Stack Exchange will be a better site for you. That site is specific to all of your gaming code needs.
精彩评论