objective c - Accessing UINavigationController from other file -


!!!yes, it's noob question, yeah.

so created navigation controller in file1, contains table view. cells in table view custom cells, having different class , xib (file2). on file2 xib, have button, when clicked, should push view navigation controller.

now don't know how refer, file2, navigation controller created in file1.

edit: fixed setting navigation controller in appdelegate , creating shared delegate, if set navigation controller in file1?

in case prefer having delegate in file2.

the .h file this

#import <foundation/foundation.h>  @protocol customcelldelegate <nsobject> - (void)buttonclicked; @end  @interface customcell : uitableviewcell  @property (nonatomic, weak) id<customcelldelegate> delegate;  - (void)getimagewithcompletionhandler:(handler)completionblock;  @end 

and when creating customcellobject in file1 u need set delegate self.

customcell *customcell = … …. customcell.delegate = self; 

implement customcelldelegate in file1

- (void)buttonclicked {    // todo: push using navigation controller code. } 

the above delegation pattern. more delegates check out tutorial here

according mvc (model view controller) pattern view's job display data , controller job push or present other controller.

hope helps!


Comments