bryankeller/BLKFlexibleHeightBar

UITableView not rendered correctly

Closed this issue · 5 comments

Hi all,

I have an issue when adding the navigation bar with an UITableView. When the screen is loaded the table is not correctly rendered below the navigation bar. Once I start scrolling, the navigation bar jumps on top and from that moment the table looks fine.

Can someone has a clue what might be the problem?

img_0231
img_0232

Thanks.

You have to manually set the contentInset of your scroll view after you set up the BLKFlexibleHeightBar. Check out -viewDidLoad: in the demo project's view controllers for more info. Also the README.md covers this. Let me know if that works for you!

I've already set:

self.tableView.contentInset = UIEdgeInsetsMake(self.myCustomBar.maximumBarHeight, 0.0, 0.0, 0.0);

And prior I have:

        self.myCustomBar = [[NuggetDetailStyleBar alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.view.frame), 300) andText:self.library.name];
        SquareCashStyleBehaviorDefiner *behaviorDefiner = [[SquareCashStyleBehaviorDefiner alloc] init];
        [behaviorDefiner addSnappingPositionProgress:0.0 forProgressRangeStart:0.0 end:0.5];
        [behaviorDefiner addSnappingPositionProgress:1.0 forProgressRangeStart:0.5 end:1.0];
        behaviorDefiner.snappingEnabled = YES;
        behaviorDefiner.elasticMaximumHeightAtTop = YES;
        self.myCustomBar.behaviorDefiner = behaviorDefiner;
        [self.view addSubview:self.myCustomBar];

        self.delegateSplitter = [[BLKDelegateSplitter alloc] initWithFirstDelegate:behaviorDefiner secondDelegate:self];
        self.tableView.delegate = (id<UITableViewDelegate>)self.delegateSplitter;

The tableview is created programatically.

Do you found any solution? I have the same problem.

if tableViewData.count < 4 {
self.behaviorDefiner.snappingEnabled = true
UIView.animateWithDuration(0.4, delay: 0, options: UIViewAnimationOptions.TransitionNone, animations: { () -> Void in
self.headerView.behaviorDefiner.snapToProgress(0, scrollView: self._imageTableView)
}, completion: { (finished) -> Void in
self._imageTableView.setNeedsLayout()
self._imageTableView.layoutIfNeeded()
})
}

If i have 4 rows left and delete one, the header scrolls down but my tableview is under the header.

I've changed the tableview created programatically with an auto layout widget from interface builder and it worked.

I didn't have the time to check more deeply a solution for my case in which the tableview was added programatically.

ok this worked for me now

UIView.animateWithDuration(0.4, delay: 0, options: UIViewAnimationOptions.TransitionNone, animations: { () -> Void in
self.headerView.behaviorDefiner.snapToProgress(0, scrollView: self._imageTableView)
self._imageTableView.setContentOffset(CGPointMake(0, -280), animated: false)

                }, completion: { (finished) -> Void in

                    self._imageTableView.setNeedsLayout()
                    self._imageTableView.layoutIfNeeded()
                })