Ios 8 UITableView: do not click "delete" to edit the deletion status. The temporary solution is suspended on the page. iosuitableview

Source: Internet
Author: User

Ios 8 UITableView: do not click "delete" to edit the deletion status. The temporary solution is suspended on the page. iosuitableview
In ios8 UITableView, edit the deletion status (isEditing: YES). If you do not click the delete button and click another location, the UITableView is suspended and cannot be moved. If you click "invalid", userInteractionEnabled: YES, isEditing: NO (picture 3 ---> Picture 4 );
In earlier versions (such as ios5), if you do not click "delete", the UITableView will return to the editing status (picture 3 ---> picture 2 ).

Solution: When you do not click "delete" to edit the Deletion Status of ios8 and click another location, the tableView: canEditRowAtIndexPath method is displayed on the page (this method is not available for earlier versions). The last item in the list is determined, tableView. isEditing = NO; reloadData (picture 3 ---> picture 2)

-(Void) viewDidLoad {[super viewDidLoad]; UIBarButtonItem * barBtnItemRight = [[UIBarButtonItem alloc] initWithTitle: @ "delete" style: UIBarButtonItemStyleDone target: self action: @ selector (edit :)]; self. navigationItem. rightBarButtonItem = barBtnItemRight; [barBtnItemRight release];}-(void) edit :( id) sender {if ([self. navigationItem. rightBarButtonItem. title isEqualToString: @ "View"]) {self. navigationItem. rightB ArButtonItem. title = @ "delete"; [self. dataTableView setEditing: NO animated: YES];} else {self. navigationItem. rightBarButtonItem. title = @ "View"; [self. dataTableView setEditing: YES animated: YES] ;}}-(BOOL) tableView :( UITableView *) tableView canEditRowAtIndexPath :( NSIndexPath *) indexPath {// modify the Deletion Status of ios8. If you do not click the "delete" button, this method is displayed. The last item in the list is tableView. isEditing = NO; When tableView is editing, the list is refreshed (reloadData) if (indexPath. row + 1 = self. listArray. count &&! TableView. isEditing & [self. navigationItem. rightBarButtonItem. title isEqualToString: @ "View"]) {[self. dataTableView setEditing: YES animated: NO]; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {dispatch_async (dispatch_get_main_queue (), ^ {[self. dataTableView reloadData];});} return YES ;}

Another point is that when the page is in the "Image 3" status in IOS8, the program will flash back when you click "return to the previous page. WTF: When you leave the page, you can set the edit status of TableView to solve this problem.

- (void)viewWillDisappear:(BOOL)animated{    [super viewWillDisappear:animated];    [self.dataTableView setEditing:NO animated:NO];}

Operation status chart:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.