ios - Adding a navigation controller to a tab bar application -
i have 2 questions one. first, have navigation controller put in storyboard , linked tabs , working how want to. except 1 thing. when try add code such this
[self.navigationcontroller poptoviewcontroller:vc animated:yes]
error property 'navigationcontroller' not found on object of type 'appdelegate *'
is because put in wrong place? or becasue tabbar application , aint right.
it sounds you're trying make call navigation controller appdelegate. unless you've setup appdelegate work navigation controller (it'd need subclass of uiviewcontroller
), you'll error because there no navigation controller on appdelegate class (by default). therefore, when make call - navigation controller can't found. notice how appdelegate subclass of uiresponder
, not uiviewcontroller
:
@interface appdelegate : uiresponder <uiapplicationdelegate>
instead, create , / or connect navigation controller uiviewcontroller
subclass - can make calls subclass:
[self.navigationcontroller poptoviewcontroller:vc animated:yes];
to create , setup navigation controller, follow these steps (may vary if aren't using storyboards).
- create new
uinavigationcontroller
obj-c subclass. in xcode menu bar, selectfile > new
, or press cmd+n. name class , set superclassuinavigationcontroller
:
note don't absolutely need entirely new class! can use existing class subclass ofuiviewcontroller
- longnavigationcontroller
property available. - add navigation controller objects library in xcode , set way need it.
- select navigationcontroller in storyboard, open utilities panel, , select identity inspector tab. set
custom class
name name ofuiviewcontroller
oruinavigationcontroller
subclass: - from class you'll able use
navigationcontroller
property, among hundreds of others relating view controller. remember appdelegate place setting app , handling app events (ex. app closing, app backgrounding, app opening).
Comments
Post a Comment