當UIButton被點擊以顯示UIPopovercontroller時,它顯示在另一個UIbarbuttonitemand上並顯示空白的黑色不透明UIPopovercontroller。UIPopoverController顯示在另一個按鈕上
這裏是我的實現代碼:
- (IBAction)buttonTapped:(id)sender {
UIButton *btnAction;
BookmarkViewController* bookmarkVC = [[BookmarkViewController alloc] init];
_buttonPopoverController = [[UIPopoverController alloc]
initWithContentViewController:bookmarkVC];
_buttonPopoverController.delegate = self;
CGRect popoverFrame = btnAction.frame;
[_buttonPopoverController setPopoverContentSize:CGSizeMake(320, 355) animated:NO];
//only required if using delegate methods
[_buttonPopoverController presentPopoverFromRect:popoverFrame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
你是如何設置'UIButton的* btnAction'到正確的按鈕? – Alexander
使用故事板連接buttonTapped – user1120133
那可能是你的問題了。您需要根據提供給函數的'(id)sender'的某些屬性來選擇按鈕,或者只需將發送者分配給按鈕:'* btnAction = sender' – Alexander