外形
- (void)backToPreview{
[self.navigationController popViewControllerAnimated:NO];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"搜索结果";
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.hidden = NO;
// self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backToPreview)]; //颜色总是蓝色,too ugly
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
[leftButton setImage:[UIImage imageNamed:@"返回.png"] forState:UIControlStateNormal];
[leftButton setTintColor:[UIColor blackColor]];
leftButton.frame = CGRectMake(0, 0, 25, 25);
[leftButton addTarget:self action:@selector(backToPreview) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
}
导航控制器中的left和right按钮隐显
- (void)showTheButtonItems{
//取消搜图
if (self.navigationItem.leftBarButtonItem == nil) {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(clearAssets)];
}
//搜图
if (self.navigationItem.rightBarButtonItem == nil) {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(searchPhotos)];
}
}
- (void)clearAssets
{
self.tabBarController.tabBar.hidden = NO;
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.rightBarButtonItem = nil;
[self.imageArr removeAllObjects];
//enable照片选取键
self.selectBtn.enabled = YES;
self.selectBtn.backgroundColor = [UIColor yellowColor];
}