1

如果alertview用户取消alertivew.

- (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");
    }
}

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

谁能帮我解决这个问题?

4

1 回答 1

1

UIalertviewdelegate 中有一个函数为

如果您有两个按钮,则功能如下

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if (buttonIndex == 1) {
      // this is normal button 
   }    
   else if (buttonIndex == 0) {
      // this is cancel button 
   }
}
于 2013-08-21T07:30:45.857 回答