如果图像的帧被更改,UITapGestureRecognizer不在UITableViewCell中的UIImageView上工作

时间:2013-09-24 13:29:03

标签: ios uitableview uigesturerecognizer uitapgesturerecognizer

我有一个奇怪的问题。我在

中创建了一个UIImageView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)theIndexPath

我在其中添加UITapGestureRecognizer以放大图片(如果已点击)。现在,根据单元格中的文本,我可能会调整UITableView单元格的大小,或者不在我的自定义单元格的- (void)layoutSubviews方法中。如果我最终必须更改UIImageView的框架以便为文本添加空间,我的UITapGestureRecognizer将不再起作用。但是,如果文本不够长并且我按原样保持ImageView,则手势完全正常。

关于如何解决这个问题的任何想法?

- (void)layoutSubviews
{
    _newsContentTextView.text = _newsContent;

    CGFloat height = [self getTextFieldHeightForText:_newsContent withFont:[UIFont systemFontOfSize:16.0f] andWidth:defaultContentWidth]; // Take into account the insets

    CGFloat textHeight = height;

    if(![_newsImageURL isEqualToString:@""])
    {
        CGRect frame = _newsPicture.frame;

        if([_newsVideoURL isEqualToString:@""])
        {
            frame.origin.x = 272.0f;
            frame.origin.y = height + defaultNewsContentY + 10;
            height += heightMultimediaContent;
        }
        else
        {
            frame.origin.x = 394.0f;
            frame.origin.y = height + defaultNewsContentY + 10 - heightMultimediaContent;
        }

       _newsPicture.frame = frame;
       _newsPicture.hidden = NO;
    }  
    else
    {
        _newsPicture.hidden = YES;
    }

    if(height > minimumContentHeight)
    {
        CGRect newsFrame = _newsContentView.frame;
        newsFrame.size.height = height + defaultNewsContentY;
        _newsContentView.frame = newsFrame; 
        CGRect newsContentFrame = _newsContentTextView.frame;
        newsContentFrame.size.height = textHeight;
        _newsContentTextView.frame = newsContentFrame;
    }
    else
    {
        _newsContentView.frame = CGRectMake(defaultContentXPosition, defaultContentYPosition, 624, defaultContentHeight);
       _newsContentTextView.frame = CGRectMake(5, 76, defaultContentWidth + 5, minimumContentHeight);
    }
}

0 个答案:

没有答案