-1

私は、ユーザーが uitableview でいくつかの nsstring オブジェクトを表示するアプリを作成しています。それらが押されると、deatilviewcontroller に入ります。ユーザーがuinavbaritemを押すと、対応するセルのデータが別のView Controllerに渡されるように、お気に入りに追加する機能を実装しようとしています。

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 に答える