ios - Label in custom view not updating -
i have created custom uiview in xib class infopopupview. add viewcontroller. works , custom class xib set in file's owner. can set titlelbl variable in first viewcontroller no problem.
my problem appears when in viewcontroller want use infopopupview again different title... title not change/update. if infopopupview remembers last title set , dont care changing it..
how can initialise? titlelbl variable in infopopupview class can change later?
any appreciated - thank !
viewcontroller
var popupview: infopopupview! popupview = infopopupview(frame: cgrectmake(0, 0, 300, 268)) popupview.titlelbl.text = "myfirsttitle" view.addsubview(popupview)
custom class
class infopopupview: uiview { var view: uiview! @iboutlet weak var okbtn: uibutton! @iboutlet weak var titlelbl: uilabel! @iboutlet weak var textview: uitextview! @ibaction func didtapokbtn(sender: anyobject) { nsnotificationcenter.defaultcenter().postnotificationname("popupcontroller", object: nil) } override init(frame: cgrect) { super.init(frame: frame) setup() } required init?(coder adecoder: nscoder) { super.init(coder: adecoder) setup() } func setup() { view = loadviewfromnib() view.frame = bounds view.autoresizingmask = [uiviewautoresizing.flexiblewidth, uiviewautoresizing.flexibleheight] addsubview(view) } func loadviewfromnib() -> uiview { let bundle = nsbundle(forclass: self.dynamictype) let nib = uinib(nibname: "infopopupview", bundle: bundle) let view = nib.instantiatewithowner(self, options: nil)[0] as! uiview return view } }
Comments
Post a Comment