我有一个奇怪的问题。我在
中创建了一个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);
}
}