i am passing my UINavigationController by reference to another class . but it is showing an error Address of property expression requested .
MyUtil *util =[[MyUtil alloc] init];
[util NavAndBackBtn:&self.navigationController];// giving error here..
MyUtil.m
-(void)NavAndBackBtn:(UINavigationController **)nav // ** for passing by reference
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:@"icon_back.png"] forState:UIControlStateNormal];
[button setFrame:CGRectMake(0,0,36,20);
UIBarButtonItem *barbtn = [[UIBarButton alloc] initWithCustomView:btn];
//*nav.navigationController.navigationItem.leftBarButtonItem = barbtn;// this gives error
//then i set this nav to Util nav
self.main_nav_ofUtilClass = *nav;
sefl.main_nav_ofUtilClass.navigationItem.leftBarButtonItem =barbtn;
}
Problem
how can i pass UINavigationController by reference . so that whatever changing i did to UINavigationController in another class happens to it.
I simply want to add a back button image to UINavigationController in another class name MyUtil
I think you have made mistake in method name
-(void)NavAndBackBtn:(UINavigationController **)nav
use insted of this
-(void)NavAndBackBtn:(UINavigationController *)nav
Remove **
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.