2011-06-02 60 views
0

我使用的是UIAlertView中有消息同行斷開 .Back地面工程/餘下的編碼沒有工作駁回it.there是一個叫繼續按鈕。只有在繼續點擊按鈕後,我才需要處理剩餘的代碼。 也我需要退出我的應用程序中取消按鈕click.can任何人告訴我一個很好的方法來做到這一點。擴展UIAlertView的功能?

我的代碼是:

UIAlertView *alertView; 
alertView = [[UIAlertView alloc] initWithTitle:@"Peer Disconnected!" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"Continue", nil]; 
[alertView show]; 
[alertView release]; 
+0

看到我的編輯答案並辦理該鏈接 – 2011-06-02 06:16:46

+0

知道了[[NSThread mainThread]退出] – Christina 2011-06-02 06:17:38

+0

然後將其標記爲正確或給予好評 – 2011-06-02 06:18:15

回答

1

您可以撥打UIAlertView中的委託方法說明如下......

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
     if (buttonIndex == 0) { 
      //Your Code //For First Button 
     } else if (buttonIndex == 1) { 
      //Your Code //For Second Button 
     } 
} 

請點擊此Link退出應用程序

+0

基本上我是C#developer.tell我退出我的應用程序在目標c中的代碼。 – Christina 2011-06-02 06:14:14

+1

@Sharmain期望的是應用程序永遠不應該自行退出。 – 2011-06-02 06:16:17

+0

如果沒有互聯網連接,並且您的應用程序需要始終連接到互聯網。例如城市勺子應用程序。 – 2011-06-02 06:18:46

0
UIAlertView *alertView; 
alertView = [[UIAlertView alloc] initWithTitle:@"Peer Disconnected!" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue", nil]; 
[alertView show]; 
[alertView release]; 

實施此委託方法。

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
if(buttonIndex == alertView.cancelButtonIndex) { 
// Cancel operation... 
}else if (buttonIndex == alertView.firstOtherButtonIndex) { 
// Continue operation... 
} 
} 
+0

基本上我是C#developer.tell我退出我的應用程序在目標c中的代碼。 – Christina 2011-06-02 06:13:31

+0

推薦文章http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application和http://stackoverflow.com/questions/1707685/how-to-quit-an-iphone-app -nicely – 2011-06-02 06:15:53

+0

明白了[[NSThread mainThread] exit] – Christina 2011-06-02 06:17:51

1

試試這個: -

UIAlertView *alertView; 
alertView = [[UIAlertView alloc] initWithTitle:@"Peer Disconnected!" message:nil delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"Continue", nil]; 
[alertView show]; 
[alertView release]; 


- (void)alertView:(UIAlertView *)alert didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if(buttonIndex==0) 
    { 
NSLog(@"cancel clicked"); 
    } 
    else if(buttonIndex==1) 
    { 
NSLog(@"continue clicked"); 
    } 
    }