首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TableView细胞不与其DetailView通讯。

TableView细胞不与其DetailView通讯。
EN

Stack Overflow用户
提问于 2012-01-20 18:05:03
回答 1查看 63关注 0票数 1

我有一个叫TableViewController的SecondViewController。单元格的名称是可以的,一切都很好,但是在加载详细视图(在我的例子中称为ArticleViewController )时,它不希望与详细视图的属性通信。因此,基本上,如果我想在详细的视图中更改一个标签,它就是不能工作。

以下是代码:

SecondViewController.h

代码语言:javascript
复制
@interface SecondViewController : UITableViewController 
{
    NSMutableArray *json;
}

@end

SecondViewController.m

代码语言:javascript
复制
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    ArticleViewController *article = [self.storyboard instantiateViewControllerWithIdentifier:@"ArticleViewController"];
    NSDictionary *info = [json objectAtIndex:indexPath.row];
    NSLog(@"%@",[info objectForKey:@"username"]);
    [article.usernameLabel setText:[info objectForKey:@"username"]];

    [self.navigationController pushViewController:article animated:YES];


}

ArticleViewController.h

代码语言:javascript
复制
#import <UIKit/UIKit.h>

@interface ArticleViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *usernameLabel;
@property (weak, nonatomic) IBOutlet UILabel *articleTitle;

@end

ArticleViewController.m

-合成性能--

我把标签和ArticleViewController挂上了钩,但是标签没有变。

EN

回答 1

Stack Overflow用户

发布于 2012-01-21 07:02:27

我猜article在执行article.usernameLabel setText:时还没有加载它的nib。所以article.usernameLabel仍然是nil。您可以通过执行article来强制[article view]加载它的nib。但奥德奈里的建议更好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8945868

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档