I have a tableviewcell, in which I am displaying the title of an RSS feed, its date and the website name. Below this, I have a text field where I am displaying a short description. I want the user to be able to tap on any part of the tableviewcell to navigate to a new screen. At present, I am able to do that only when I tap on the part of the cell that has the title, date and website, but not on the part that has the textview with the description. Can I possibly implement such a thing?? If so how do I do it?
- (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;
}