- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"QuestionCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
} else { // if there is already a subview, remove it
while ([[cell.contentView subviews] count] > 0) {
UIView *labelToClear = [[cell.contentView subviews] objectAtIndex:0];
[labelToClear removeFromSuperview];
}
}
UIFont *myFont = [UIFont fontWithName:@"Arial" size:18.0];
UITextView *lblQuestionTitle = [[UITextView alloc] init];// initialise your textView here, including setting its contentOffset
lblQuestionTitle.text = [[questions objectAtIndex:indexPath.row] objectForKey:@"questionTitle"];
CGSize textSize = [lblQuestionTitle.text sizeWithFont:myFont constrainedToSize:lblQuestionTitle.frame.size lineBreakMode:UILineBreakModeWordWrap];
lblQuestionTitle.contentOffset = CGPointMake(textSize.width, textSize.height);
[cell.contentView addSubview:lblQuestionTitle];
return cell;
}