2013-08-21 48 views
1

我有问题alertview当我试图显示一些文本,如果用户取消alertivewuialertview与条件if语句在ios

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset 
{ 
    UIALertView alertview = [[UIAlertView alloc] initWithTitle:@"New Answer" 
              message:@"Your text" 
                delegate:self 
                cancelButtonTitle:@"Cancel" 
                otherButtonTitles:@"OK", nil]; 

    [alert show] 

    if (buttonIndex == 0) 
    { 
     NSLog(@"ok"); 
     [[self sectionSelectedDisplay] setText:answerLabel]; 
    } 
    else 
    { 
     NSLog(@"cancel"); 
    } 
} 

+++++++++++++++++++++++++

谁能帮我解决这个问题?

+1

所以,你要的NSLog的alertview按钮按下的指数? – Woodstock

+0

该问题尚不清楚。你到底需要什么帮助? –

+0

@Puneet:我编辑了代码。那是我的功能。这[[self sectionSelectedDisplay] setText:answerLabel];不在if语句内工作。 – Aragon

回答

1

存在UIalertviewdelegate作为

的功能,如果你有两个按钮,然后功能的工作原理如下

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 1) { 
     // this is normal button 
    }  
    else if (buttonIndex == 0) { 
     // this is cancel button 
    } 
}