简体   繁体   中英

How to enable userinteraction in tableview when coming back to tableview

In my app I am doing tableView. By clicking row, the new view will navigate. Before navigation of new view, application is processing data from server. Until processing of data finished, view will not navigate. In this time period I want to disable userinteraction of tableview, so user can not select further rows.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    tableView.userInteractionEnabled = NO;
}

Note that, When I again come back to the tableview, user will again allowed to select any row. I do not have any idea, how can I enable userinteracation again.

For Coming back after navigation, Put following sentence in your viewWillAppear That will again allow your table view user interaction to true.

tableView.userInteractionEnabled = YES;

I assume that you are getting your data asynchronously. In this case, you can re-enable user interaction from your connection delegate method. If you are using NSURLRequest/NSUrlConnection, the delegate method would be: connectionDidFinishLoading: (don't forget also about connection:didFailWithError: ).

From NSURLConnection Reference :

connectionDidFinishLoading:

Sent when a connection has finished loading successfully.

So, when the data is there and you are done with the processing, you re-enable the table view.

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