segue to viewController UILabel不显示文本

时间:2013-05-05 14:57:35

标签: objective-c

我有一个来自tableViewController的segue到一个带有UILabel的viewController来显示文本(注释),但是文本没有出现。

例如:

- (void)viewDidLoad
{
[super viewDidLoad];


list = [[NSMutableArray alloc] init];

 wine *barbera =[[wine alloc] init];
[barbera setName:@"Barbera"];
[barbera setNotes:@"stuff about this..."];
[list addObject:barbera];

wine *chardonnay=[[wine alloc]init];
[chardonnay setName:@"Chardonnay"];
[chardonnay setNotes:@"stuff about this..."];
[list addObject:chardonnay];

wine *cheninBlanc =[[wine alloc]init];
[cheninBlanc setName:@"Chenin Blanc"];
[cheninBlanc setNotes:@"stuff about this... "];
[list addObject:cheninBlanc];

我的观点:

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
DescriptionWineViewController * dwvc= [segue destinationViewController];
[dwvc setCurrentWine :[self currentWine]];
}

我也尝试过:

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
DescriptionWineViewController * dwvc= [segue destinationViewController];
[dwvc setNotes :[self notes]];
}

并且viewController是要转到:

@interface DescriptionWineViewController ()

@end

@implementation DescriptionWineViewController

@synthesize descriptionLabel;
@synthesize currentWine;
@synthesize notes;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad

{
[super viewDidLoad];

[descriptionLabel setText: [currentWine notes]];

 }

如果您需要更多信息,请与我们联系。

1 个答案:

答案 0 :(得分:0)

问题可能出在currentWine。您需要在tableView:didSelectRowAtIndexPath:中实现此功能,以将其设置为所选项目。