UIAlertView控件的警报模式不能通过添加UIAlertAction来解除

时间:2016-07-28 22:50:02

标签: ios objective-c

我几乎在这里阅读了所有相关文章,但仍然无法得到警告。有人可以帮忙吗?它不应该那么难......

P.S。在defaultAction回调中,我尝试了两个:

[self dismissViewControllerAnimated:YES completion:^{
                                                                  NSLog(@"ok...");
                                                              }];

NSLog(@"ok...");

两者都不走运

我的代码:

#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) UIAlertController *alert;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidAppear:(BOOL)animated {
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Reminder"
                                                                   message:@""
                                                            preferredStyle:UIAlertControllerStyleAlert];
    self.alert = alert;
    self.alert.message = @"You just logged in. The tab will be refreshed";
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                          handler:^(UIAlertAction * action) {
                                                              [self dismissViewControllerAnimated:YES completion:^{
                                                                  NSLog(@"webview is reloading...");
                                                              }];

                                                          }];

    [self.alert addAction:defaultAction];
    [self presentViewController:self.alert animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

2 个答案:

答案 0 :(得分:1)

它会自我解雇。如果你

app/src/**/*.js

使用然后它将关闭当前View contrtoller,其中警报控制器在解除后显示日志。

[self dismissViewControllerAnimated:YES completion:^{
              NSLog(@"webview is reloading...");
          }];

答案 1 :(得分:0)

关闭。你只需稍作调整即可。

My data looks like below:     
unit price    quantity     salesperson   date
$10             5               A         1/1
$10             6               B         1/1
$30             9               A         1/1
$30             10              B         1/1
$10             3               A         1/2
$10             5               B         1/2
$20             7               A         1/2
$20             8               B         1/2