【问题标题】:custom back button image does not work on the navigation bar自定义后退按钮图像在导航栏上不起作用
【发布时间】:2010-01-04 09:31:18
【问题描述】:

我创建了一个自定义导航返回按钮。但是当我添加这段代码时,我的背部动画不起作用,它会返回动画。为什么?我认为这取决于我的@selector 操作。

- (void)viewDidLoad {


    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"goback.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(//HERE ! i don't know put what thing !) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(0, 0, 32, 32)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
}

【问题讨论】:

  • 只是一个注释...不需要写 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];可以直接写 self.navigationItem.leftBarButtonItem = button

标签: iphone button sdk


【解决方案1】:

好的,我创建了一个函数并且工作正常:D:

-(void)pushNav {
[self.navigationController popViewControllerAnimated:YES];  
}

【讨论】:

  • 方法可能应该被称为 popNav 以适应功能
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-03
  • 1970-01-01
  • 1970-01-01
  • 2016-04-01
  • 1970-01-01
  • 2015-12-16
  • 1970-01-01
相关资源
最近更新 更多