单击按钮时为什么会出现错误?

时间:2016-09-19 09:20:43

标签: objective-c

快照未呈现的视图会导致空快照。当我在ios上点击按钮使用UIActionsheet时,确保您的视图在屏幕更新后的快照或快照之前至少呈现一次?为什么呢?

- (IBAction)btnAboutUsActions:(UIButton *)sender
{
    UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil
                                                              delegate:self
                                                     cancelButtonTitle: nil
                                                destructiveButtonTitle: nil
                                                     otherButtonTitles: @"Achievment",
                                                                        @"Brown Story", nil];
    actionSheet.tag = 100;

    [actionSheet showFromRect: sender.frame inView: sender.superview animated: YES];

}

1 个答案:

答案 0 :(得分:0)

使用alertController

UIAlertController *alert = [UIAlertController alertControllerWithTitle:confirmText message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *achievment = [UIAlertAction actionWithTitle:@"Achievment"
                                                       style:UIAlertActionStyleDefault
                                                     handler:nil];
[alert addAction: achievment];
[self presentViewController:alert animated:YES completion:nil];
[alert.view layoutIfNeeded]
相关问题