0

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
    }
}
Thlbaut
  • 649
  • 7
  • 25

1 Answers1

0

I would point you to this post: Swipe to Delete not working

Make sure you implement all the necessary methods, and you don't have a unusual view hierarchy/code running on the app delegate.

I vaguely remember an issue with storyboards and tableview controllers that are embedded inside a view controller. Perhaps someone else can shed more light on this.

Community
  • 1
  • 1
emma ray
  • 13,336
  • 1
  • 24
  • 50
  • I forgot I had a gesture recognizer: my Navigation Controller has a Slide Menu. There was a conflict. Thank you for your previous comment ! – Thlbaut May 05 '14 at 14:36
  • that would do it! FYI, you can still use the gesture on the nav controller, if you pass on left-swipes to the UITableView as mentioned here: http://stackoverflow.com/questions/4454920/gesture-recognizers-and-tableview – emma ray May 05 '14 at 14:41