UIAlertController uyarı eylem düğmelerini, hedef-c kullanarak eylem işleyicileriyle nasıl bağlarım? Xcode 7.1 kullanıyorum. Bunu demek düşünüyorumBir UIAlertController eylemini nasıl ele alırım?
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title" message:@"text mssg" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
// Ok action example
}];
UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"Other" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
// Other action
}];
[alert addAction:okAction];
[alert addAction:otherAction];
[self presentViewController:alert animated:YES completion:nil];
:
- (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];
}
Dokümanları okumalısın. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/#//apple_ref/doc/uid/TP40014538-CH1-SW4 – Dare
Zaten bunu okudum.ama düğmelerini eylem ile bağlamak istiyorum . – ghoshghosh
Bunun için ne olduğunu. - actionWithTitle: stil: işleyici: Bu eylemleri UIAlertController'a eklersiniz. – Dare