wannabegeek / PlaceholderTableView

UITableView subclass which presents a custom view when empty
The Unlicense
5 stars 0 forks source link

Doesn't show 'no items here' when first started up. #1

Open benvium opened 11 years ago

benvium commented 11 years ago

When I run this code on the iOS 6 simulator, I only get the 'no rows here' label after clicking Edit and then Done.

MarcoTansini commented 11 years ago

in iOS6 in the loadView method calls the setEditing method on the tableview, but at that time the view hierarchy is not yet totally instantiated. So the placeholder gets added to the tableView's superview that is still nil and the implementation assumes that has been added.

Quick and not yet properly tested solution: replace "_placeHolderVisible = YES" in the displayPlaceholderIfNeeded method with: _placeHolderVisible = _placeHolderView.superview != nil && _placeHolderView.superview == self.superview; This makes sure that the placeholder has actually been added to a view (the same as tableview superview).

It's an old post but i hope this helps someone :)