Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select the UITableViewCell over the UITextView losing ability to call didSelectRowAtIndexPath Delegate Method?

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?

like image 976
Musthafa Avatar asked May 17 '12 10:05

Musthafa


1 Answers

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.

like image 134
Suresh Varma Avatar answered Oct 03 '22 23:10

Suresh Varma