I have some apps designed for iOS 6 and today I went to upgrade them to iOS 7.
They are a simple table view lists and when a record is selected it displays details about that row on another screen. This worked flawlessly in iOS 6. With iOS 7 when I select a row it shows a blank data page on the first selection. If I then go back to the list and reselect the item it then displays the proper data.. After this first blank display it will work fine for any other records..
I am racking my brain and can not for the life of me figure out why this is happening.
Any ideas?
CODE:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Statutes *statute = (Statutes *)[self.statutes objectAtIndex:indexPath.row];
if(self.detailView == nil) {
DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
self.detailView = viewController;
[viewController release];
}
[self.navigationController pushViewController:self.detailView animated:YES];
self.detailView.title = [statute myStatute];
[self.detailView.statuteFullText setText:[statute myDescription]];
[self.detailView.statuteTitle setText:[statute myTitle]];
[self.detailView.favoritesID setText:[statute myPriority]];
[self.detailView.recordID setText:[statute myRecord]];
if ([@"1" isEqualToString:[statute myPriority]]) {
[self.detailView.favoriteControl setTitle:@"Remove from favorites"];
} else {
[self.detailView.favoriteControl setTitle:@"Add to favorites"];
}
}
Also, the part that changes the button title Add to Favorites etc, does not change on the first item selection, it simply shows "Item".
Thanks.
UPDATE:
So I narrowed it down to this piece of code:
if(self.detailView == nil) {
DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
self.detailView = viewController;
[viewController release];
}
If I remove the if clause then it happens on every selection. If I comment out the whole code I cant make any selections. So I imaging I have to find another way to initialize my view controller. Any ideas? Why did this work in iOS 6 then?