简体   繁体   English

可编程UI控件

[英]Programmable UI Control segue

I am implementing facebook login using the programmably created facebook login button. 我正在使用可编程创建的Facebook登录按钮来实现Facebook登录。 Now after sucessfully logining in, I want to open another view. 现在成功登录后,我想打开另一个视图。 My problem is since I cannot see the programmably created button in the storyboard, I am not able to control -drag to create a segue to open another view. 我的问题是,由于无法在情节提要中看到可编程创建的按钮,因此我无法控制-drag来创建segue来打开另一个视图。 How can I fire a segue without control-draging. 我如何在不进行控制的情况下触发segue。 Thanks in advance for your answer. 预先感谢您的回答。

You can detect the click of the button by adding a target to your button: 您可以通过向按钮添加目标来检测按钮的单击:

button.addTarget(self, action: Selector("buttonClicked"), forControlEvents: UIControlEvents.TouchUpInside)

And create a function named buttonClicked like this: 并创建一个名为buttonClicked的函数,如下所示:

func buttonClicked(){
    var nextView:[Your view class name] = self.storyboard?.instantiateViewControllerWithIdentifier("[id of your view]") as [Your view class name]

    self.presentViewController(nextView, animated: true, completion: nil)
}

You can set the id of your viewController by selecting your new view in the storyBoard and then going in the identity inspector and setting the storyBoard id to what you want 您可以通过在storyBoard中选择新视图,然后进入身份检查器并将storyBoard ID设置为所需的值来设置viewController的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM