Wednesday, 15 June 2011

Changing UINavigationBar title in iOS8 Swift -



Changing UINavigationBar title in iOS8 Swift -

i have programmatically added uinavigationbar in superview called baseviewcontroller inherits uiviewcontroller. when seek set title uinavigationbar. error called fatal error: can't disclose optional.none

below swift class. how can disclose , alter uinavigationbar title

import uikit class baseviewconroller: uiviewcontroller { var navbar:uinavigationbar=uinavigationbar() override func viewdidload() { super.viewdidload() setnavbartotheview() // additional setup after loading view. navbar.topitem.title="test test" } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func setnavbartotheview() { navbar.frame=cgrectmake(0, 0, 320, 50) navbar.backgroundcolor=(uicolor .blackcolor()) self.view .addsubview(navbar) } }

replace navbar.topitem.title="test test" self.title="test test". cheers!!

uinavigationbar swift ios8

No comments:

Post a Comment