2016-09-19 106 views
0

對未呈現的視圖進行快照會產生空的快照。當我使用UIActionsheet單擊ios按鈕時,確保您的視圖在屏幕更新後的快照或快照之前至少呈現一次?爲什麼?爲什麼點擊按鈕時顯示錯誤?

- (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]; 

} 

回答

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] 
+0

感謝您的建議。但是,我想使用ActionSheet呢?因爲我必須在點擊按鈕時執行多個選項並且多個選項視圖顯示在按鈕下方。 –

+0

嘗試在顯示它之後寫入[[actionSheet.view layoutIfNeeded]]。 – pkc456

+0

我已經試過了! [actionSheet layoutIfNeeded];它不工作! –

相關問題