不会出现在代码中手动添加的视图

时间:2014-12-16 21:53:07

标签: ios

一旦用户双击图像/屏幕,它就会在屏幕上添加注释。当它添加注释图像时,我还想打开一个子视图来添加注释细节。但是,我的子视图没有出现。 这是我的代码段。

  @synthesize iViewController;

 - (void)viewDidLoad {
     [super viewDidLoad];

    // adding gesture recognizer
      UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
        tapGesture.numberOfTapsRequired = 2;
        [self.imvPhoto addGestureRecognizer:tapGesture];
        tapGesture.delegate = self;
    }

 - (void)handleTapGesture:(UITapGestureRecognizer *)sender {
        if (sender.state == UIGestureRecognizerStateRecognized) {

        // Here is the code for subview adding
        iViewController = [[InventoryViewController alloc] init];
        [self.view addSubview:iViewController.view];
        iViewController.view.frame = CGRectMake(100, 100, 320, 460);

    }
}

enter image description here

1 个答案:

答案 0 :(得分:0)

基于@rdelmar反馈,这是解决方案:

 iViewController = (InventoryViewController *)[self.storyboardinstantiateViewControllerWithIdentifier:@"InventoryViewController"];
            iViewController.view.frame = CGRectMake(728, 32, 300, 736);
            [self.view addSubview:iViewController.view];