alekseyn / EasyTableView

Horizontal and vertical scrolling table views for iOS
BSD 3-Clause "New" or "Revised" License
584 stars 157 forks source link

reloadData not working? #3

Closed mattejames closed 13 years ago

mattejames commented 13 years ago

Hi, I'm using EasyTableView in my project and loving it. However, I've run into an issue and I'm not sure if it's my code or EasyTableView, so I thought I'd ask.

In my code, based on a user selection, I'm switching out the delegate for EasyTableView and calling [easyTableView.tableView reloadData] directly so that it hits up the new delegate with a new data set. Unfortunately, when I do this, the delegate methods are not getting called. I also jumped into the EasyTableView code attempting to debug, but the UITableView delegate methods you implement on EasyTableView aren't getting called either. I just wanted to check with you to see if this was a design constraint of EasyTableView or if I was perhaps mis-using it somehow. Any help is greatly appreciated!

alekseyn commented 13 years ago

EasyTableView was designed to be the delegate and data source for tableView. You must not change the tableView delegate or data source. If you need access to additional tableView delegate or data source methods, I would recommend you edit EasyTableView and provide additional delegate methods that forward the tableView delegate or data source call to EasyTableView's delegate. As a template on how to do this please look at:

alekseyn commented 13 years ago

Thanks for that clarification. What you are trying to do should work fine. Does the other delegate implement the EasyTableViewDelegate protocol? That's the only thing I can think of. You can try setting a breakpoint on the EasyTableView method:

After you call reloadData, you can then step through to see why the delegate method is not getting called.

mattejames commented 13 years ago

Yep, I tried that and unfortunately, the method was never called. I then tested a similar tactic in your default EasyTableView sample project and it seems to have worked fine. I have no idea where I could be going wrong, but apparently it has to do with my project. Sorry for wasting your time.

alekseyn commented 13 years ago

If you have a sample project that causes the problem, I would be happy to look at it.

mattejames commented 13 years ago

Thanks very much for the offer. I really appreciate it. Unfortunately, at this point it's all sort of mixed in with the whole project and wouldn't be easy to pull out.

In other news, I've found a lead! I'll let you know what I find out.

mattejames commented 13 years ago

Oh my God it was incredibly simple. I hate that!

For my dataSource, I'm using an object that conforms to NSFetchedResultsControllerDelegate. During a data update, these methods get called which talk to the tableView directly. And, for apparently no reason whatsoever, I commented out the [easyTableView.tableView endUpdates] method call on my controllerDidChangeContent: method. Ugh!

Thanks again for EasyTableView - I had no idea originally that this could be done to get a UITableView to display horizontally and had gone WAY out of my way to write a custom view that extended UIScrollView. Your code saved me many hours of development and bug fixing! Sorry again to waste your time. :)