Я хочу отобразить предупреждение. Но поскольку uialertView устарел для iOS 8, что я могу сделать, чтобы отобразить предупреждение для обоих видов ОС?Используйте UIAlertView и UIAlertController для того же приложения
0
A
ответ
1
Попробуйте этот фрагмент кода, чтобы отобразить представление предупреждения в iOS8.Это определенно будет работать.
- (IBAction) btn1Clicked: (UIButton *) отправителя {
// оповещения стиль
UIAlertController сигнал тревога * = [UIAlertController alertControllerWithTitle: @ "ALERT!" сообщение: @ «Что вы будете делать?» preferredStyle: UIAlertControllerStyleAlert];
__weak ViewController *wself = self;
// Make choices for the user using alert actions.
**UIAlertAction** *doSomethingAction = [UIAlertAction actionWithTitle:@"I'm doing something" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
__strong ViewController *sself = wself;
sself.alertResponseLabel.text = @"You did something!";
}];
UIAlertAction *doNothingAction = [UIAlertAction actionWithTitle:@"I'm totally ignoring this" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
__strong ViewController *sself = wself;
sself.alertResponseLabel.text = @"OK, just ignore me...";
}];
// Add actions to the controller so they will appear
[**alert addAction:doSomethingAction];
[alert addAction:doNothingAction];**
alert.view.tintColor = [UIColor blackColor];
**[self presentViewController:alert animated:YES completion:nil];** }
возможно дубликат [Показаны предупреждение iOS7, iOS8 и] (http://stackoverflow.com/questions/26229587/showing-alert-with-ios7-ios8-both) – gsanllorente
дублируется ... Это это то, что я искал. Спасибо! –