2011-01-11 38 views
0

我試圖將用戶引導到新場景,如果他輸入正確的代碼,但它不起作用。下面是代碼:UIAlertView和UITextFields不工作

- (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中代表。

感謝,

泰特

+1

移至gamedev.stackexchange.com? – AttackingHobo 2011-01-11 21:29:16

回答