43

アプリの UIAlertController で問題が発生し、Date Picker が内部にある iOS8 に移行されました。

以下はコードです。

UIAlertController *AlertView = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];

 UIAlertAction *ok = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)
{
[AlertView dismissViewControllerAnimated:YES completion:nil];
}];

 UIAlertAction *set = [UIAlertAction actionWithTitle:NSLocalizedString(@"Set to today", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)
{
[self set_to_today:nil];
[AlertView dismissViewControllerAnimated:YES completion:nil];
[self.tableView reloadData];
}];

 UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)
{
[AlertView dismissViewControllerAnimated:YES completion:nil];
}];


 UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
 datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker setDate:data_appo];
[datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];

[AlertView.view addSubview:datePicker];
[AlertView addAction:ok];
[AlertView addAction:set];
[AlertView addAction:cancel];
[self.view bringSubviewToFront:datePicker];
[self presentViewController:AlertView animated:YES completion:nil];

ユーザーが UITableViewController から行を選択すると、UIAlertController と Date Picker が表示されます。

問題は次のとおりです。ユーザーが最初に行を選択すると、すべて正常に動作します...しかし、ユーザーが「キャンセル」を選択してから再度削除を選択すると、UIAlertController が表示されるまでに 2 ~ 3 秒かかります...これは、シミュレーター...

私は夢中になっています....これにより、アプリのユーザーエクスペリエンスが低下します。

どんな助けでも大歓迎ですありがとう

アレックス

4

2 に答える 2

92

UITableView から行を選択することによって提示される UIAlertController で同じ問題が発生していました。最初はすべて正常に機能し、ユーザーがアラートを再度トリガーしたとき、アラートが実際に表示されるまでに数秒の遅延がありました。

回避策として、GCD を使用しました。

    dispatch_async(dispatch_get_main_queue(), ^{
        [self presentViewController:AlertView animated:YES completion:nil];
    });

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPathメインスレッドで既に実行されているため、おそらくバグです。

Apple にバグレポートを提出しました: rdar://19285091

于 2014-12-17T22:04:49.753 に答える