单击UIView Pass数据并在Objective c中从UIView Data设置为Navigationitem标题

时间:2017-02-04 13:59:13

标签: ios objective-c uiview

我在firstVC中有很多视图,如果我在视图数据集中选择任何一个视图作为第二个VC的navigationItem标题,则视图有3个对象。

     firstVC:
        //UIView set Action

            UITapGestureRecognizer *singleFingerTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
            View1.tag = 1;
            [View1 addGestureRecognizer:singleFingerTap1];


            UITapGestureRecognizer *singleFingerTap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
            view2.tag = 2;
            [view2 addGestureRecognizer:singleFingerTap2];

            UITapGestureRecognizer *singleFingerTap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
            view3.tag = 3;
            [view3 addGestureRecognizer:singleFingerTap3];

            }

        -(void)handleSingleTap:(UITapGestureRecognizer *)sender
        {

            UIView *viewClicked = sender.view;
            NSLog(@"Clicked: %ld",(long)viewClicked.tag);

             [self performSegueWithIdentifier:@"Segue" sender:self];


        }

        -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
        {
            if ([segue.identifier isEqualToString:@"Segue"])
            {
                DetailsViewController *controller = (DetailsViewController *)segue.destinationViewController;
                controller = [segue destinationViewController];
                controller.DataValue = arrayValue;

            }
        }

它的传递数据正确但不能在点击时为每个视图设置navigationItem标题。

secondVC:     另一个帮助有20个元素(比如20 index[0][20])我不想为每个索引编写代码,如下所示,我不知道如何编写代码{ {1}}(不是0到20)

objectAtIndex:some

0 个答案:

没有答案