लियो जवाब देने के लिए पर जोड़ने, हाँ, वहाँ UIAlertController
contentViewController
पर एक निजी प्रॉपर्टी में आप एक UIViewController
UIAlertController
की सामग्री के रूप में (और यह है दृश्य) स्थापित करने के लिए अनुमति देता है।
आप KVO का उपयोग कर या तो जैसे एक निजी हैडर आयात किए बिना इस संपत्ति का उपयोग करने के लिए एक निजी इंटरफ़ेस बना सकते हैं: फिर
@interface UIAlertController (ContentViewController)
@property (nonatomic, strong) UIViewController * contentViewController;
@end
, में अपने कस्टम दृश्य लेआउट अपनी सामग्री को देखने नियंत्रक के view
, इंटरफ़ेस बिल्डर या प्रोग्राम के रूप में के माध्यम से ।
याद रखें कि आप भी अपने दृश्य नियंत्रक के preferredContentSize
ओवरराइड करने के लिए की जरूरत है:, बल्कि गेटर अधिभावी से, सिंह नतन preferredContentSize
सीधे स्थापित करने का सुझाव के बाद से यह UIViewController
पर एक संपत्ति है:
- (CGSize)preferredContentSize {
CGSize contentSize = [super preferredContentSize]; //gets the preferredContentHeight from the view, will be set depending on how much content we have
return CGSizeMake(contentSize.width, self.view.preferredContentHeight);
}
नोट।
यदि आप चाहें तो अपने उप-वर्ग में भी अपने व्यू कंट्रोलर के view
को ओवरराइड कर सकते हैं।
के रूप में अपने अलर्ट सेट कर अपने सामान्य:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message"
preferredStyle:UIAlertControllerStyleActionSheet];
अपने कस्टम दृश्य सेट करें:
[alertController setContentViewController:[[MyContentViewController alloc] init]];
अपने कार्यों जोड़ें:
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^{
NSLog(@"Cancel Button was pressed");
}];
के रूप में अपने सामान्य वर्तमान:
[self presentViewController:alertController animated:YES completion:nil];
UIAlertController
के निजी एपीआई पर अधिक जानकारी आईफोन देव विकी के article on UIAlertController पर मिल सकती है।
मैं _UIAlertControllerActionView
और UIAlertAction
, साथ ही साथ UIAlertActionViewRepresentation_Internal
प्रोटोकॉल पर निजी इंटरफेस भी देखता हूं।
वैसे भी uialertviewcontroller से uitableview पॉप करने के लिए है। – SMS
आप इस कार्यक्षमता को केवल UITableView के माध्यम से प्राप्त करना चाहते हैं .. – Ricky
मेरा उत्तर देखें। मैंने इसे कई बार लागू किया है, और यह बहुत आसान है। –