I am having an issue with my UITableViewCell
selection.I am using a UITableViewCell
with a UITextView
sub view. The UITextView
object is not editable, not scrollable, with user interaction enabled.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell=[[[NSBundle mainBundle]loadNibNamed:@"DemoCell" owner:self options:nil]objectAtIndex:0];
cell. accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
if([distanceArray count]){
UILabel *label1=(UILabel*)[cell viewWithTag:1];
label1.text=[locationNameArray objectAtIndex:[indexPath section]];
label1.textColor=[UIColor blueColor];
UILabel *label2=(UILabel*)[cell viewWithTag:2];
[label2 setText:[distanceArray objectAtIndex:[indexPath section]]];
UITextView *tview=(UITextView*)[cell viewWithTag:3];
[tview setText:[discriptionArray objectAtIndex:[indexPath section]]];
return cell;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetailedLocationVIew *dView=[[DetailedLocationVIew alloc]initWithNibName:@"DetailedLocationVIew" bundle:nil];
[self.navigationController pushViewController:dView animated:YES];
[dView release];
}
If i select the cell over the UITextView
, the delegate didSelectRowIndexPath
not calling. Apart from over UITextView
object and selection works fine?
Why Selection Not working Over UITextView?
Use tview.userInteractionEnabled=NO;
and It will solve your problem.
If this doesn't solve your problem then try this out
for(UIView * cellSubviews in cell.subviews)
{
cellSubviews.userInteractionEnabled = NO;
}
It loops for all the subviews within cell and sets userInteractionEnabled
property to NO
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With