dzenbot / DZNEmptyDataSet

A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display
https://www.cocoacontrols.com/controls/dznemptydataset
MIT License
12.09k stars 1.73k forks source link

Buttons not registering tap events #16

Closed Dysonapps closed 10 years ago

Dysonapps commented 10 years ago

The buttons returned (shown) from

- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state;

aren't registering touch events. The button appears to be displayed properly but tapping them does nothing on devices running iOS 7.x using Xcode 5.1.1. However, the buttons are working properly in the iOS 8 betas.

Thanks, Wes

dzenbot commented 10 years ago

I have just tested installed the Applications sample project to an iOS7 device, and button touch events work properly here.

Can you show a "Color blended layers" preview of the render in the simulator? Specially to see the details of your empty dataset layout.

Something like this: image

Also, are you returning YES for emptyDataSetShouldAllowTouch:

Dysonapps commented 10 years ago

I am indeed returning YES but it turns out those delegate methods are never called. I've setup the delegate and copied the loadView method.

screen shot 2014-07-06 at 5 00 46 pm

dzenbot commented 10 years ago

Is your tableview conforming to both protocols?

self.tableView.emptyDataSetSource = self;
self.tableView.emptyDataSetDelegate = self;
Dysonapps commented 10 years ago

Yep

dzenbot commented 10 years ago

I'd need to read more of your code to understand where's the problem. Please create a private gist of your view controller implementation and send it over to iromero@dzen.cl

dzenbot commented 10 years ago

Are you using the latest pod, version 1.3.2?

Dysonapps commented 10 years ago

I am indeed.

dzenbot commented 10 years ago

Can you try not having an UIToolBar? By commenting

if ([self.navigationController isToolbarHidden] == YES) {
    [self.navigationController setToolbarHidden:NO animated:NO];
}

I haven't tested this with that kind of layout. It may not make a difference. Just to know.

Dysonapps commented 10 years ago

Tried that but made no difference unfortunately.

dzenbot commented 10 years ago

The setup seems to be ok. I've copy 'n pasted the methods you're implementing for displaying and interacting with the empty dataset, and it does work here: image

There's probably something intercepting the touch input of the tableView. Does it scroll when empty?

Dysonapps commented 10 years ago

I had it set to not scroll but if I change the following to YES, it does scroll properly.

dzenbot commented 10 years ago

I read your code over and over, and can't figure this out. Sorry. You'll need to dig into the DZNEmptyDataSet and log why the gesture and button are not being called.

I'd suggest to build a fresh new UITableViewController, only with the empty dataset setup, and see from there if it works. It must be something interfering...

Let me know if you find a solution.

Dysonapps commented 10 years ago

No worries, just wanted you to be aware of it really, it's also evident in the 2 other view controllers I've used it in (same project). I can't understand why it's working for iOS 8 but not 7.x.

dzenbot commented 10 years ago

I haven't tested this library with iOS8 yet. Still, I've never encounter this bug before, and I'm using the library in 3 apps and 3 sample projects.

Have you tried the sample projects already? I hope you'll figure it out, and submit a PR if there's actually something wrong in the library. My guess is that there's something in your code interfering with touch input on the tableviews.

Dysonapps commented 10 years ago

Yes, tried them and they all work fine. I'll keep plugging away.

Dysonapps commented 10 years ago

Update:

The problem seems to be caused by the UISearchBar from a storyboard-created UISearchDisplayController.

When I remove the UISearchBar from the Storyboard, the button works correctly. Unless I'm misunderstanding, there's no way to remove the SearchBar from the search controller and re-add it unless you create a new search controller every time you want to re-enable search.

Any ideas for a possible work-around?

dzenbot commented 10 years ago

That's really weird. I've just updated the Colors sample project, which uses UISearchDisplayController with the normal UISearchBar, and couldn't reproduce the bug. Please take a look into it, and keep me posted.

Thanks

Dysonapps commented 10 years ago

I've tested the issue against the Colors app and was able to recreate the problem.

All I did was add a UISearchDisplayController and its UISearchBar to the UITableView in the Storyboard.

screen shot 2014-07-08 at 3 56 22 pm

The button doesn't register the tap events either.

The Search TVC works fine because you're modifying the searchResultsTableView instead of modifying a tableView who's controller also has a searchResultsController.

Dysonapps commented 10 years ago

Solution:

In the colours app, add a UISearchDisplayController to the TableViewController class and the corresponding UISearchBar to the tableView in the Storyboard.

Change numberOfRows to

This re-enables the button.

dzenbot commented 10 years ago

Fixed with #18