Swift: Create button that leads to new view -
i wanted know how i'd programmatically, without use of storyboard, able make button when pressed leads viewcontroller.
let button = uibutton(type: uibuttontype.system) button.settitle("button", forstate: uicontrolstate.normal) button.sizetofit() button.addtarget(self, action: "loadviewcontroller", forcontrolevents: uicontrolevents.touchupinside) self.view.addsubview(button)
loadviewcontroller method in controller loads view controller.
func loadviewcontroller() { let vc = uiviewcontroller(nibname: "viewcontroller", bundle: nil) self.presentviewcontroller(vc, animated: true, completion:nil) }
Comments
Post a Comment