简体   繁体   中英

UITableView inside UITableViewCell

I have the UITableView ( tableA ) with custom cells( cellA ). Inside of each cell I have some views and UITableView ( tableB ) with Custom cells( cellB ). There is a button in each cellB . I need to handle the TouchUpInside action from this buttons, but when user taps outside buttons I need to animate cellA selection and call method -(void)didSelectRowAtIndexPath from tableA delegate. In other words, user should select cellA then he taps outside button, tableB should miss this action for tableA . How can I do this?

I tried to set userInteractionEnabled property to false for tableB and cellB , but in this case buttons became disabled.

In the delegate of tableB, implement didSelectRowForIndexPath to make table A select the current row. The row will only receive the action if the touch wasn't on the button.

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableA selectRowAtIndexPath:indexPathThatContainsTableB];
}

You may need to call the delegate method for tableA's delegate yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM