inamiy / YIFullScreenScroll

Pinterest-like scroll-to-fullscreen UI for iOS5+.
http://www.cocoacontrols.com/controls/yifullscreenscroll
214 stars 27 forks source link

Question: How to disable ScreenScroll if cell count < a specific number #11

Closed ghost closed 11 years ago

ghost commented 11 years ago

My cells do have a special height. So if there are only 5 results in my tableView, the scrollview isn't long enough to display a scrollbar, but the screenScroll is active anyway. Problem: One cell is hidden by the tabBar.

Question: How can I deactivate the screenScroll (when activated in viewDidLoad) without any issues?

inamiy commented 11 years ago

Thanks for feedback! Please try above commit and tell me your thought.

inamiy commented 11 years ago

By the way, to answer your question, there are enabled and layoutingUIBarsEnabled properties which can turn/lock on/off the fullscreening behavior. You can try them too :)

ghost commented 11 years ago

Perfect :)

ghost commented 11 years ago

Now there is another little problem: in a normal and long tableView, the height of the tabBar is added at the bottom.

inamiy commented 11 years ago

Keeping scrollView.contentInset.bottom for tabBar (current spec) is recommended since there may be a time to show tabBar again (e.g. via -showUIBarsAnimated:).

You can also check and see current demo with toolbar-style-viewController (nav-pushed one), which also leaves bottom white space for toolbar.

I would say this is a better spec, but if you want to cut bottom space manually, you can further adjust scrollView.contentInset on -viewDidAppear.

ghost commented 11 years ago

The problem is, I have to wait for the cell count before I can set the inset.

Best solution would be: If the cells do not fill the full screen (without nav- and tabBar), the fullScreenScroll should be disabled automatically.

inamiy commented 11 years ago

Do you mean, your tableViewDataSource is not still ready on -viewDidAppear and needs more waiting? (e.g. fetching cell data via web) Then, try setting tableView.contentInset.bottom on every -reloadData which should have calculated total height as tableView.contentSize.height.

ghost commented 11 years ago

Ok. I am able to remove the space when results are > than 5. But I can't reset the space when they are < than 5..

There is also a 1px line of the navBar (under the hidden navBar), when I scrolled to the bottom. You'll see it, if you turn the background color into black.

inamiy commented 11 years ago

Your code should be something like this. You might have forgotten '2. content height is too short' part.

- (void)reloadTableView
{
    [self.tableView reloadData];

    // 1. content height is long enough
    if (self.tableView.contentSize.height > self.tableView.frame.size.height) {
        self.tableView.contentInset.bottom = 0; // no tabBar space please!
    }
    // 2. content height is too short
    else {
        self.tableView.contentInset.bottom = 49; // OK, I'll add tabBar space as default behavior
    }
}

And '1px line of the navBar' may be another issue, so please open it as new GitHub issue, and if possible, sending me a new demo app is really appreciated :)

ghost commented 11 years ago

I can do what I want. Either there is space or not. Your code does not work for my project.

You generally added a space. But you should "add space if cells do not fill the screen".

inamiy commented 11 years ago

OK, I understand your saying "should add space if cells do not fill the screen".

But from library side, it is not easy to check whether content height is really short or not, since this library is not only for UITableView but also for any other UIScrollView subclasses e.g. UIWebView, UICollecitonView. Also, if tabBar-space adjustment is needed, there will need bottom toolbar-space adjustment too, and code will be messier and hard to maintain. Always adding whitespace is not really a bad spec (I rather think it is good!), so I will leave this issue as user's side (e.g. adjustment in reloadData).

If library-side implementation is still needed for you, it is probably a good time to fork and implement with your code :)