मान लीजिए कि आप एक चेतावनी से पता चला है जहां प्रतिनिधि के लिए था "स्व"
- (void)showAlert {
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"My Alert"
message:@"Do you want to continue?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"No", @"Yes", nil];
[myAlert show];
[myAlert release];
}
आदेश में चलो अपने .m फ़ाइल में काम करने के लिए निम्नलिखित:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
आपका ज फ़ाइल की आवश्यकता होगी कार्यान्वयन वक्तव्य में UIAlertViewDelegate को संदर्भित करने के लिए:
@interface myViewController : UIViewController <UIAlertViewDelegate> {
}
यह वही है जो y UIAlertViewDelegate विधि कॉल का जवाब देने के लिए हमारी .m फ़ाइल।
मैं ब्लॉक कॉलबैक साथ UIAlertView प्रतिनिधिमंडल की जगह के लिए एक सामान्य वर्ग में लिखा था। आप इसे यहां देख सकते हैं [http://stavash.wordpress.com/2013/01/31/quick-tip-uialertview-with-a-block-callback/)। – Stavash