从Storyboard添加controllerview会取消在我视图中分配给UIImageViews的TapGesture

时间:2012-12-06 18:55:00

标签: objective-c ios uiimageview ios6 uistoryboard

所以在一个视图中,让我们说“A”,我有多个UIImage视图和UITextViews。现在,这都是以编程方式完成的。在同一视图中,我这样做:

if(!_productionLinesCollectionViewController)
{
    _productionLinesCollectionViewController = [[self storyboard]instantiateViewControllerWithIdentifier:@"ProductionLinesCollection"];
    _productionLinesCollectionViewController.productionLines = [_plant.productionLines allObjects];
    _productionLinesCollectionViewController.initX = 0;
    _productionLinesCollectionViewController.initY = _totalHeight;
    _productionLinesCollectionViewController.width = 668;
}

[self.scrollView addSubview:_productionLinesCollectionViewController.view];

现在由于某种原因,这是“取消”我之前分配的所有UITapGestures(在同一视图中)(此外,此代码在其他一些视图中100%工作)。每当我删除这段代码时,我的手势再次起作用。有什么想法吗?

谢谢!

UIImageView *playMovieImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"press_to_play.png"]];
playMovieImage.frame = CGRectMake(30, _totalHeight, 608, 456);
UITapGestureRecognizer *tapRecognizer;
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playMovie:)];
[playMovieImage addGestureRecognizer:tapRecognizer];
playMovieImage.userInteractionEnabled = YES;
[self.scrollView addSubview:playMovieImage];

0 个答案:

没有答案