-1

我正在制作一个应用程序,用户在 uitableview 中看到几个 nsstring 对象,当它们被按下时,它会进入 deatilviewcontroller。我正在尝试实现添加到收藏夹功能,因此当用户按下 uinavbaritem 时,相应单元格的数据将被传递到另一个视图控制器。

GrillTips *tips1 = [GrillTips new];
tips1.name = @"Tändvätska";
tips1.info = [NSArray arrayWithObjects:@"Tändvätska", nil];

GrillTips *tips2 = [GrillTips new];
tips2.name = @"Kol";
tips2.info = [NSArray arrayWithObjects:@"Kolen är det viktigste inom grillning", nil];


GrillTips *tips3 = [GrillTips new];
tips3.name = @"Få det Varmt!";
tips3.info = [NSArray arrayWithObjects:@"tjena", nil];


GrillTips *tips4 = [GrillTips new];
tips4.name = @"tjo";
tips4.info = [NSArray arrayWithObjects:@"what", nil];



GrillTips *tips5 = [GrillTips new];
tips5.name = @"tjo";
tips5.info = [NSArray arrayWithObjects:@"what", nil];


GrillTips *tips6 = [GrillTips new];
tips6.name = @"tjo";
tips6.info = [NSArray arrayWithObjects:@"what", nil];


GrillTips *tips7 = [GrillTips new];
tips7.name = @"tjo";
tips7.info = [NSArray arrayWithObjects:@"what", nil];



GrillTips *tips8 = [GrillTips new];
tips8.name = @"tjo";
tips8.info = [NSArray arrayWithObjects:@"what", nil];


GrillTips *tips9 = [GrillTips new];
tips9.name = @"tjo";
tips9.info = [NSArray arrayWithObjects:@"what", nil];




tips = [NSArray arrayWithObjects:tips1, tips2, tips3, tips4, tips5, tips6, tips7, tips8,    tips9, nil];
4

1 回答 1

3
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"yourSegueIdentifier" sender:self];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender //Pass your array here
{
    YourViewController *controller = (YourViewController*)segue.destinationViewController;
    controller.passedArray = theArrayYouWantToPass;//where passedArray is an array property inside of the viewController that you are segueing to
}
于 2013-07-01T23:55:33.563 回答