【发布时间】:2011-08-21 12:08:15
【问题描述】:
我放入了一个自定义的“返回”UIBarButtonItem,它来自我在 Photoshop 中制作的图像。我设法让它看起来很好,我的问题是让它工作。
我的按钮什么都不做,我假设是因为我没有为它分配任何操作。我只是不知道这样做的正确语法吗?
这是我的代码
UIImage *buttonImage = [UIImage imageNamed:@"BackButton.png"];
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
backButton.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
// Im assuming this is where i need to put the action...
//[backButton addTarget:self action:@selector(.......) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithCustomView:backButton];
基本上,我希望我的新自定义后退按钮能够像常规 UITableView 中的默认后退按钮一样工作
问候, 安迪
【问题讨论】:
标签: ios uitableview uinavigationbar uibarbuttonitem