0

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

例如:

- (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]];

 }

如果您需要更多信息,请告诉我。

4

1 回答 1

0

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

于 2013-05-05T15:29:41.657 回答