Question

So I'm trying to push a UITableViewController from another controller and the search bar on my UITableViewController doesn't show up.

Here's my .m for the original table. (attempting to push to the "xSearch" view controller)

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath



xSearch *itemSearch = [[xSearch alloc] init];


}

if([[tableData objectAtIndex:indexPath.row]isEqual:@"Search"]){

    [itemSearch setTitle:[tableData objectAtIndex:indexPath.row]];

    [self.navigationController pushViewController:itemSearch animated:YES];

}

In my storyboard, the "xSearch" viewcontrolelr consists of a table and a search bar. But only the table shows. Any help would be greatly appreciated. By the way, I'm not trying to code the search bar. I'm just wondering why it doesn't appear when I run the app.

Was it helpful?

Solution

Because you are not initializing itemSearch using storyboard. You should initialize it using storyboard like-

NSString *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; //specify your storyboard name

xSearch *itemSearch = [storyBoard instantiateViewControllerWithIdentifier:@"xSearchStoryboardIdentifier"]; //You need to provide storyboard id in storyboard(Identity Inspector)

And then push it

[self.navigationController pushViewController:itemSearch animated:YES];

OTHER TIPS

It might be due to re-sizing issue, navigation bar might be hiding the search bar. Try hiding the navigation bar using:

setNavigationBarHidden:animated:

In your nib file change the view property to view with navigation controller.. Then design your XIB.. Study this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top