【发布时间】:2013-09-28 07:32:49
【问题描述】:
我之前在我的应用程序中完成了以下代码。它适用于除 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 中都可以正常工作
【问题讨论】:
-
我在这里得到了同样的结果。我用 nib 初始化一个 detailViewController,进行推送,然后将所选项目中的字符串传递给 detailViewController 的标签。标签没有更新..有什么解决办法吗??
-
你在你的 init 方法中改变它?在 init 方法中传递它,然后将它分配给其他一些 NSString,然后在 viewDidLoad 方法中设置标题。
-
不,我在 didSelectRowAtIndexPath 中初始化了一个新的 detailViewController。这个新的 detailViewController 有一个 IBOutlet,一个标签。推送后我分配标签文本,但它没有改变(在 iOS 7 中不起作用,这在所有以前的 iOS 中都有效。是模板代码)
-
@Frade if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { titleiOS7 = [dataDict objectForKey: kNestedDataKey_title]; [NSTimer scheduleTimerWithTimeInterval:0.5 target:self 选择器:@selector(change) userInfo:nil repeats:NO]; } -(void)change{ nextController.title = titleiOS7; }
-
谢谢马什哈迪!我提出了一个与此问题相关的问题。 Check it here。检查正确答案上的 cmets。
标签: iphone uinavigationbar title ios7