I implemented a UITableview
with all methods.
When the UITableviewController
is the initial View Controller, it works fine, I can swipe to delete.
But when the UITableViewController
is part of my project and reached by pushing the view, I can't swipe to delete. It seems the application doesn't always detect the swipe or something like this, because sometimes, the delete button appears.
This is a very simple project, there is no big operation.
(I'm using Google Analytics et Google Adsense library, but not in this view controller.)
---
EDIT : Some code and a question, the code of the previous screen may influence the performance of the uitableviewcontroller ?
My storyboard is like this :
[Navigation controller] --> [Root View Controller] --> [Table View Controller]
Code :
VerreTableViewController.h
@interface VerreTableViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *table_view_verres;
@end
VerreTableViewController.m
@interface VerreTableViewController ()
@end
NSArray *objects_verres;
@implementation VerreTableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
objects_verres = [Verre allWithOrder:@{@"date_prise" : @"DESC"}];
_table_view_verres.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return objects_verres.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [_table_view_verres dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
UILabel *lbl_nom = (UILabel *)[cell viewWithTag:10];
UILabel *lbl_date = (UILabel *)[cell viewWithTag:11];
NSManagedObject *matches = objects_verres[indexPath.row];
lbl_nom.text = [matches valueForKey:@"nom_alcool"];
lbl_date.text = [[matches valueForKey:@"date_prise"] formattedDateWithFormat:@"HH:mm - dd/MM/yyyy"];
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//code to delete
}
}