inamiy / YIFullScreenScroll

Pinterest-like scroll-to-fullscreen UI for iOS5+.

Home Page:http://www.cocoacontrols.com/controls/yifullscreenscroll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YIFullScreenScroll is not compatible with UIRefreshControl

jk opened this issue · comments

I got this in my tableview's viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update"];
    [refreshControl addTarget:self action:@selector(updateNewsItems) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refreshControl;

    self.fullScreenScroll = [[YIFullScreenScroll alloc] initWithViewController:self scrollView:self.tableView];
    self.fullScreenScroll.shouldShowUIBarsOnScrollUp = NO;
    self.fullScreenScroll.shouldHideToolbarOnScroll = NO;
    self.fullScreenScroll.shouldHideTabBarOnScroll = NO;
}

The refresh control is visually below the UINavigationBar. So the padding of UIRefreshControl to the top is too narrow. But I'm not sure if this is fixable - perhaps you got a clue.

Hm... It seems, setting refreshControl and navigationBar.translucent = YES at same time
causes messed layout, even when not using fullScreenScroll at all.
(Please note that fullScreenScroll always force-set translucent to YES)

One easy solution would be to adjust refreshControl.frame on every scroll.
There is YIFullScreenScrollDelegate method for additional layouting,
so please use it instead of UIScrollViewDelegate's -scrollViewDidScroll for better performance.

Looks like we should update the podspec. The delegation code (and others like the __weak references) isn't tagged and therefor not in the CocoaPod spec. Can you tag a new version? I'll update the podspec, since I got write access there, if you like.

Sorry for that!
But there are little more improvements going on and I want to take care for versioning,
so can you use this line instead of fetching from CocoaPods/Specs for a while?
Thanks.

pod 'YIFullScreenScroll', :git => 'https://github.com/inamiy/YIFullScreenScroll.git', :commit => 'ecb5217b6746a3d4bf6790f46e049493c210c162'

Yeah, no problem and there is a good reason to postpone the podspec update.

So, the following make it work and I'll close this issue:

- (void)fullScreenScrollDidLayoutUIBars:(YIFullScreenScroll*)fullScreenScroll {
    if (self.refreshControl
        && self.navigationController.navigationBar
        && !self.navigationController.navigationBar.hidden) {
        CGRect newFrame = self.refreshControl.frame;
        newFrame.origin.y += self.navigationController.navigationBar.frame.size.height;
        self.refreshControl.frame = newFrame;
    }
}