1

我之前在我的应用程序中完成了以下代码。它适用于除 iOS7 之外的所有 iOS。我正在更改 didSelectRow 方法中的导航标题,但它没有更改我在 iOS 7 中的导航栏标题。我在运行时在 didselectrow 中创建了一个新控制器,并在此行中给它一个标题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];
}

注意:它在除 iOS 7 之外的所有 iOS 中都可以正常工作

4

2 回答 2

1

我注意到 iOS 7 中有一个奇怪的行为,即视图加载到内存中有点晚。因此,当您设置标题时,可能尚未创建标题标签。所以在设置瓷砖之前使用这个语句。这将确保您的视图已创建并在内存中。[下一个控制器视图]; 在此设置标题之后 nextController.title = @"Title"; 祝你好运

于 2013-09-23T12:45:24.317 回答
1

试试这个代码

 - (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];
}
于 2013-09-23T12:02:45.177 回答