0
RSS 피드의 제목, 날짜 및 웹 사이트 이름을 표시하는 tableviewcell이 있습니다. 이 아래에는 간단한 설명을 표시 할 텍스트 필드가 있습니다. 나는 사용자가 새로운 화면으로 이동하기 위해 tableviewcell의 어떤 부분을 탭 할 수 있기를 원한다. 현재 제목, 날짜 및 웹 사이트가있는 셀의 부분을 탭할 때만 설명 할 수 있지만 설명이 포함 된 텍스트 뷰가있는 부분에는 액세스 할 수 없습니다. 나는 그런 것을 구현할 수 있을까 ?? 그렇다면 어떻게해야합니까?테이블 뷰 셀 위에있는 텍스트 뷰를 클릭하여 탐색 할 수 없습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NewsCell *cell = (NewsCell*)[tableView dequeueReusableCellWithIdentifier:@"NewsViewCell" forIndexPath:indexPath];
cell.titleLabel.text = [[feeds objectAtIndex:indexPath.row] objectForKey: @"title"];
NSString *site = [[feeds objectAtIndex:indexPath.row] objectForKey:@"link"];
if ([site rangeOfString:@"dailymail"].location != NSNotFound) {
site = @"Daily Mail";
}
else if (![site rangeOfString:@"theguardian"].location != NSNotFound){
site = @"The Guardian";
}
else if (![site rangeOfString:@"football.co.uk"].location != NSNotFound) {
site = @"Football UK";
}
else if (![site rangeOfString:@"football365"].location != NSNotFound) {
site = @"Football 365";
}
cell.siteLabel.text = site;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat: @"dd-MM-yyyy HH:mm:ss"];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSString *dateString = [dateFormat stringFromDate:[[feeds objectAtIndex:indexPath.row] objectForKey:@"pubDate"]];
cell.pubDateLabel.text = dateString;
NSString *newsDescription = [[feeds objectAtIndex:indexPath.row] objectForKey:@"description"];
CGRect textRect = [newsDescription boundingRectWithSize:CGSizeMake(310,NSUIntegerMax) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:12]} context:nil];
CGSize stringSize = textRect.size;
textV=[[UITextView alloc] initWithFrame:CGRectMake(5, 50, 310, stringSize.height+25)];
for(UIView *subview in cell.contentView.subviews)
{
if([subview isKindOfClass: [UITextView class]])
{
[subview removeFromSuperview];
}
}
if ([newsDescription isEqualToString:@""])
{
newsDescription = @"Preview not available";
textV.font = [UIFont italicSystemFontOfSize:12.0];
textV.textColor = [UIColor grayColor];
}
else
{
textV.font = [UIFont systemFontOfSize:12.0];
textV.textColor = [UIColor blackColor];
}
textV.text = newsDescription;
textV.textAlignment = NSTextAlignmentLeft;
textV.editable = NO;
[cell.contentView addSubview:textV];
return cell;
}