Bog*_*nov 2 popup storyboard segue swift
我以编程方式将 UIButton 附加到导航栏:
catButton.addTarget(self, action: "oc:", forControlEvents: .TouchUpInside)
var catBarButton:UIBarButtonItem = UIBarButtonItem(customView: catButton)
self.navigationItem.setRightBarButtonItem(catBarButton, animated: false)
Run Code Online (Sandbox Code Playgroud)
当函数 oc() 被触发时,我想弹出视图控制器
let segue = UIStoryboardSegue(identifier: "oc", source: self, destination: MDComDBCatsTVC())
prepareForSegue(segue, sender: but)
Run Code Online (Sandbox Code Playgroud)
但这不会打开 MDComDBCatsTVC .. 如何以编程方式执行此操作,因为我无法从故事板中的按钮拖动,因为我的按钮是以编程方式添加的
我无法从故事板中的按钮拖动,因为我的按钮是以编程方式添加的
您可以通过从视图控制器图标拖动到目标视图控制器来在故事板中创建转场。然后可以以编程方式使用此 segue。
单击 segue 以在“属性”检查器面板中分配标识符。然后可以使用此标识符以编程方式访问 segue。
Xcode 会坚持 popover segues 有一个锚点。错误消息是“Popover segue with no anchor”。这可以在属性检查器 - Anchor 属性中解决。从圆圈拖动到您的视图。
在以编程方式创建的按钮的操作中,您将能够使用例如:
func buttonAction(sender:UIButton!)
{
performSegueWithIdentifier("popoversegue", sender: self)
}
Run Code Online (Sandbox Code Playgroud)
( ... 或更可能使用更强大的东西if let等)

| 归档时间: |
|
| 查看次数: |
7949 次 |
| 最近记录: |