So right now I have the following code:
if ([[contentsList objectAtIndex:indexPath.row] isEqual:@"Hydrogen"])
{
Hydrogen *hydrogen = [[Hydrogen alloc] initWithNibName:@"Hydrogen" bundle:nil];
[self.navigationController pushViewController:hydrogen animated:YES];
hydrogen release];
}
Basically, this code says that if the row that is equal to "Hydrogen开发者_如何学编程" (this is a row in a UITableView), then it will load the XIB called "Hydrogen.xib" However, when I add a search bar to my code, the search works fine, but when I tap into the results the row that is displayed is always the first row in the table. How would I fix this, I think it has something to do with the rows in the code above...
Thanks!
You could duplicate your array, but put in the view controllers as strings instead. Then use:
Class detailClass = NSClassFromString([controllersArray objectAtIndex:[indexPath row]]);
UIViewController* detailViewController = [[[detailClass alloc] initWithNibName:nil bundle:nil] autorelease];
[self.navigationController pushViewController:detailViewController animated:YES];
精彩评论