当我搜索我的搜索数据时,一切正常,但当我从segue回来时,我的搜索栏消失了..对我做错了什么以及如何解决问题有所帮助。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"BasicCell";
UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (myCell == nil) {
myCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; }
Location *item;
if (!isFilltered) {
item = _feedItems[indexPath.row];
} else {
item = [filteredString objectAtIndex:indexPath.row];
}
myCell.textLabel.text = item.name;
myCell.detailTextLabel.text = item.city;
UIImage *myImage = [UIImage imageNamed:@"DemoCellImage"];
[myCell.imageView setImage:myImage];
return myCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (!isFilltered)
_selectedLocation = _feedItems[indexPath.row];
else
_selectedLocation = [filteredString objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:@"detailSegue" sender:self];
}
这是准备塞行
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"detailSegue"])
{
// Get reference to the destination view controller
LeadDetailViewControler *detailVC = segue.destinationViewController;
detailVC.selectedLocation = _selectedLocation;
}
}
这里是
- (void)viewDidLoad
{
[super viewDidLoad];
self.searchBar.delegate = self;
self.searchBar.hidden = YES;
self.searchBar.barTintColor = [UIColor clearColor];
self.searchBar.showsScopeBar = YES;
self.searchBar.scopeButtonTitles = @[@"name",@"city",@"phone",@"date",@"active"];
self.definesPresentationContext = YES;
}
- (void)searchButton:(id)sender {
self.searchBar.hidden = NO;
[self.searchBar becomeFirstResponder];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
self.searchBar.text=@"";
self.searchBar.hidden = YES;
[self.searchBar resignFirstResponder];
}