1

I have done the following code previously on in my app. It is working good with all the iOS other than iOS7. I am changing the navigation title in didSelectRow method but it is not changing my navigation bar title in iOS 7. I create a new controller on run time in didselectrow and giving it a title in this line nextController.title = [dataDict objectForKey: kNestedDataKey_title];

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

    NSLogDebug();
    NSDictionary *dataDict = [self.data objectAtIndex: indexPath.row];
    NSString *classNSString = [dataDict objectForKey: kNestedDataKey_class];

    UIViewController *nextController = NULL;
        nextController = [[NestedTableViewController alloc] initWithNibName: nil bundle: nil];
        [self.navigationController pushViewController: nextController animated: YES];
        ((NestedTableViewController *) nextController).data = [dataDict objectForKey: kNestedDataKey_data];


    nextController.title = [dataDict objectForKey: kNestedDataKey_title];
    [nextController release];
}

Note: It is working fine in all the iOS other than iOS 7

Mashhadi
  • 3,004
  • 3
  • 46
  • 80
  • I got the same here. I init a detailViewController whit nib, make the push, and pass a string from selected item to a label of detailViewController. the label is not updated.. Any solution?? – Frade Oct 10 '13 at 17:58
  • you are changing it in your init method? pass it in init method then assign it to some other NSString and then set title in viewDidLoad method. – Mashhadi Oct 11 '13 at 06:11
  • No, I init a new detailViewController in didSelectRowAtIndexPath. This new detailViewController has an IBOutlet, a label. After pushing i assign label text, but it doesn't change (in iOS 7 doens't work, this works in all previous iOS. is the template code) – Frade Oct 11 '13 at 13:49
  • @Frade if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { titleiOS7 = [dataDict objectForKey: kNestedDataKey_title]; [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(change) userInfo:nil repeats:NO]; } -(void)change{ nextController.title = titleiOS7; } – Mashhadi Oct 21 '13 at 06:37
  • Thanks Mashhadi! I have made a question related with this issue. [Check it here](http://stackoverflow.com/questions/19321228/tableview-didselectrowatindexpath-doesnt-work-properly-on-ios-7-why). Check the comments on the right answer. – Frade Oct 21 '13 at 17:36

2 Answers2

1

Try This code

 - (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
    NSLogDebug();
    NSDictionary *dataDict = [self.data objectAtIndex: indexPath.row];
    NSString *classNSString = [dataDict objectForKey: kNestedDataKey_class];

   NestedTableViewController *nextController = NULL;
    nextController = [[NestedTableViewController alloc] initWithNibName: nil bundle: nil];

    nextController.data = [dataDict objectForKey: kNestedDataKey_data];


     nextController.title = [dataDict objectForKey: kNestedDataKey_title];
    [self.navigationController pushViewController: nextController animated: YES];
    [nextController release];
}
Deepesh
  • 8,065
  • 3
  • 28
  • 45
  • nextController have no data and no visible files .xib or .m or .h, it is created over here on run time. or may be i am not getting you – Mashhadi Sep 23 '13 at 12:33
1

I notice a strange behavior in iOS 7, that view loads in memory bit late. so when you are setting title, it is possible label for title is not yet created. SO use this statement before setting tile. this will make sure that your View is created and in memory. [nextController view]; after this set title nextController.title = @"Title"; Good luck

Adnan Aftab
  • 14,377
  • 4
  • 45
  • 54
  • You got the root cause. [nextController view]; is not working for me but problem is that iOS7 loads a bit late so i just added an NSTimer for it with 1.0 seconds and it worked. [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(change) userInfo:nil repeats:NO]; – Mashhadi Sep 23 '13 at 13:00
  • That's great , Congrats. – Adnan Aftab Sep 23 '13 at 13:02