Wie kann ich UIAlertController Alert-Aktionsschaltflächen mit Action-Handlern mit Ziel-c verknüpfen? Ich benutze Xcode 7.1.Wie gehe ich mit den Aktionen eines UIAlertControllers um?
Hier ist mein Code:
- (IBAction)selectbtn:(UIButton *)sender {
UIAlertController *alert=[ UIAlertController alertControllerWithTitle:@"NEW" message:@"button pressed" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cameraaction=[UIAlertAction actionWithTitle:@"From camera" style:UIAlertActionStyleDefault handler:nil ];
[alert addAction:cameraaction];
UIAlertAction *libraryaction=[UIAlertAction actionWithTitle:@"From photo library" style:UIAlertActionStyleDefault handler:nil ];
[alert addAction:libraryaction];
UIAlertAction *cancelaction=[UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDestructive handler:nil];
[alert addAction:cancelaction];
[self presentViewController:alert animated:YES
completion:nil];
}
Sie müssen die Dokumente lesen. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/#//apple_ref/doc/uid/TP40014538-CH1-SW4 – Dare
Ich lese das bereits. Aber ich möchte Tasten mit Aktion verknüpfen . – ghoshghosh
Dafür ist das da. - actionWithTitle: style: handler: Sie fügen diese Aktionen dem UIAlertController hinzu. – Dare