我想显示提醒。但由于uialertView已被弃用于iOS 8,我该怎么做才能显示这两种操作系统的警报?
答案 0 :(得分:1)
尝试使用此代码段在iOS8中显示警报视图。这肯定会有效。
- (IBAction)btn1Clicked:(UIButton *)sender {
//警报风格
UIAlertController * alert = [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];** }