gpt4 book ai didi

ios - PopOver View Controller 覆盖全屏

转载 作者:搜寻专家 更新时间:2023-11-01 06:04:42 29 4
gpt4 key购买 nike

这是我的 PopOver 代码。我有两个 View Controller 。我在 Messaging View controller 中显示 PopOver,需要通过管道传输的 view controller 是 PreferencesView controller。 Storyboard Id 也是相同的 Preferences View Controller 。 popOver 成功但始终覆盖整个屏幕。即使 UIModalPresentationStyle.None。我在这里做错了什么?

 func optionClicked(sender:UIBarButtonItem)
{
print(")show set preference and set reminder option")


let preferenceAction: UIAlertAction = UIAlertAction(title: "Set preferences", style: .Default) { action -> Void in
self.optionChoosed(true)
}
let reminderAction: UIAlertAction = UIAlertAction(title: "Set reminder", style: .Default) { action -> Void in
self.optionChoosed(false)
}
let actionSheetController: UIAlertController = UIAlertController(title: kAlertTitle, message: "What you want to do?", preferredStyle: .ActionSheet)

let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
}
actionSheetController.addAction(preferenceAction)
actionSheetController.addAction(reminderAction)
actionSheetController.addAction(cancelAction)
self.presentViewController(actionSheetController, animated: true, completion: nil)
}

func optionChoosed(isSetPreference:Bool)
{


if(isSetPreference)
{
print("Set preference")

let storyboard : UIStoryboard = UIStoryboard(name: "Messaging", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("PreferencesViewController") as! PreferencesViewController
vc.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover: UIPopoverPresentationController = vc.popoverPresentationController!
popover.barButtonItem?.action = "isSetPreference"
popover.delegate = self
presentViewController(vc, animated: true, completion:nil)


}

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None

}
func dismiss() {
self.dismissViewControllerAnimated(true, completion: nil)
}

最佳答案

我猜你是从 Storyboard 中进行转场。如果您这样做,请从 Storyboard 中删除 segue 并为栏按钮项目创建一个操作并将此代码放在那里。

    let storyboard : UIStoryboard = UIStoryboard(name: "Messaging", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("PreferencesViewController") as! PreferencesViewController
vc.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover: UIPopoverPresentationController = vc.popoverPresentationController!
vc.preferredContentSize = CGSize(width: 200, height: 200)
popover.barButtonItem = sender as? UIBarButtonItem
popover.delegate = self
presentViewController(vc, animated: true, completion:nil)

关于ios - PopOver View Controller 覆盖全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40799988/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com