2013-02-09 45 views
1

在我的應用程序中執行代碼時發生錯誤,並且任務是在警報後重定向到URL。但關於代碼我的猜測是正確的......而這裏去我的代碼使用未聲明的錯誤:ViewController.m中的警報錯誤--IOS應用程序

- (void) alertStatus:(NSString *)msg :(NSString *)title :(int)tag 
{ 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title 
                 message:msg 
                 delegate:self 
               cancelButtonTitle:@"Ok" 
               otherButtonTitles:nil, nil]; 
    if (tag) alert.tag = tag; 
    { 
    [alertView show]; 
    } 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if(alertView.tag == 101) 
    { 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://ABC.company.com"]]; 
     //[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; 
    } 
} 

錯誤是顯示在該行 如果(標籤)alert.tag =標籤;(使用未聲明的標識符:警惕)

任何人都可以幫助我如何擺脫這個問題。

+0

是什麼'alert'? – 2013-02-09 11:04:52

+1

將alert添加到alertView – akshay1188 2013-02-09 14:41:49

+0

是的,您是正確的。我忘記了那件愚蠢的事情。 abyway非常感謝你.... - @ akshay1188 – 2013-02-11 07:20:23

回答

0

你有一對夫婦的...錯誤(遺漏)

  • - (void) alertStatus:(NSString *)msg **withTitle**:(NSString *)title **andTag**:(int)tag
  • if (tag) alert.tag = tag; //但以前你聲明alertView
+0

這不是主要問題。但這是需要糾正的。 – 2013-02-09 11:08:02