【问题标题】:Address of property expression requested请求的属性表达式的地址
【发布时间】:2014-09-17 08:25:34
【问题描述】:

我通过引用另一个类来传递我的 UINavigationController。但它显示错误 Address of property expression requested

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 添加一个后退按钮图像

【问题讨论】:

  • 如果添加按钮是目标,为什么不尝试使用类别?保留一个布尔值以在默认和自定义之间切换。

标签: ios uinavigationcontroller uibarbuttonitem


【解决方案1】:

我认为你的方法名弄错了

-(void)NavAndBackBtn:(UINavigationController **)nav

使用 insted 这个

-(void)NavAndBackBtn:(UINavigationController *)nav

删除**

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-27
  • 1970-01-01
  • 2012-03-20
  • 2013-01-16
  • 2011-06-20
相关资源
最近更新 更多