![](/img/trans.png)
[英]iOS: I have an error message 'Address of property expression requested'
[英]Address of property expression requested
我通过引用另一个类传递我的UINavigationController。 但它显示错误的属性表达式请求的地址 。
MyUtil * util = [[[MyUtil alloc] init];
[util NavAndBackBtn:&self.navigationController]; //在这里给出错误。
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;
}
问题
我如何通过引用传递UINavigationController 。 这样我在另一个类中对UINavigationController所做的任何更改都会发生在它上面。
我只想在另一个类名MyUtil中向UINavigationController添加后退按钮图像
我认为您在方法名称上输入了错误
-(void)NavAndBackBtn:(UINavigationController **)nav
使用这个
-(void)NavAndBackBtn:(UINavigationController *)nav
移除**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.