Make UIAlertView Button trigger function On Press

后端 未结 7 2010
小蘑菇
小蘑菇 2020-12-25 09:22

Currently I am using the following code to present a UIAlertView:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@\"Today\'s Entry Complete\"
               


        
相关标签:
7条回答
  • 2020-12-25 09:48

    If you want to use blocks you can also use MKAdditions to achieve this easily even for multiple UIAlertViews.

    Just use a code similar to this sample:

    [[UIAlertView alertViewWithTitle:@"Test" 
                            message:@"Hello World" 
                  cancelButtonTitle:@"Dismiss" 
                  otherButtonTitles:[NSArray arrayWithObjects:@"First", @"Second", nil]
                          onDismiss:^(int buttonIndex)
     {
         NSLog(@"%d", buttonIndex);
     }
     onCancel:^()
     {
         NSLog(@"Cancelled");         
     }
     ] show];
    

    You can find more information in this tutorial: http://blog.mugunthkumar.com/coding/ios-code-block-based-uialertview-and-uiactionsheet

    0 讨论(0)
提交回复
热议问题