Giter Site home page Giter Site logo

gskbyte / gskstretchyheaderview Goto Github PK

View Code? Open in Web Editor NEW
1.7K 34.0 191.0 5.55 MB

A generic stretchy header for UITableView and UICollectionView

License: MIT License

Objective-C 92.31% Ruby 1.64% C 3.53% Swift 2.51%
stretchy-headers interface-builder uikit ios uiview uiscrollview uitableview uicollectionview

gskstretchyheaderview's People

Contributors

abotkin-cpi avatar dependabot[bot] avatar gskbyte avatar jesalgadom avatar ojcarcete avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gskstretchyheaderview's Issues

Can't touch inside header view

Hi.
I have a collection view inside the stretchy header view that works as a slider but I noticed I can only touch before minimum header height for example area smaller than 60px but touch does not work between minimum and maximum height when the view is stretched.
Because of this I can't work with views and buttons inside that part and also cant scroll collection view

Snap to minimum/maximum

Hey!
Appreciate your work on this library.
I was wondering if there's a way to make the header snap to the minimum or maximum height (depending if the current stretch factor is closer to 0 or 1). I'm doing some fading of items inside but because a user can scroll a bit and make the header smaller, some text is stuck mid-fade which is weird. What I want is that as soon as the user releases the scrolling finger, the header will animate into the maximum or minimum size.

Any ideas on how can this be implemented?
Thanks!

Use it in UIScrollView

Is it possible to implement GSKStretchyHeaderView in a UIScrollView?

Thank you for this awesome contribution!

Automatic Cell problem

        self._tableView.addSubview(self.stretchyHeader)

        _tableView.estimatedRowHeight = 44.0
        _tableView.rowHeight = UITableViewAutomaticDimension

Automatic Cell working!

        _tableView.estimatedRowHeight = 44.0
        _tableView.rowHeight = UITableViewAutomaticDimension
         self._tableView.addSubview(self.stretchyHeader)

Automatic Cell not working

Pagination problems

Hi! I've been using GSKStretchyHeaderView on a project. It works great, except when I use pagination on a tableView. As soon as the tableView loads more items/rows, the header jumps back to expanded mode. Also, when scrolling through pages, it jumps between totally contracted/expanded states. (eg. if my pagination count is 5, every 5 items it jumps).
I suppose these issues are respectively related to:

  1. tableView.reloadData() fired by the pagination, which causes the header to go back to its original state.
  2. changes in the tableView's content height, which is breaking something.
    Does anyone have any idea how to solve these issues?

Sticky header with section views

Does this work with table section views? I tried to use it with section headers and the section headers end scrolling when they reach the bottom of the initial sticky header frame. So the sticky header shrinks but the section headers stop scrolling once the initial bottom point is reached even after the sticky header is shrinked. I use plain table view style.

Thanks

TabBarController issue

I have 3 ViewControllers inside a TabBarController and each ViewController has collectionView with StretchyHeader. Problem is every time i switch tab it adds 20px height to the header and stretch factor changes to 1.01.
It starts with stretch factor = 1 and frame height = 325, which I have set. But after I switch the tab frame height changes to 345 and stretch factor to 1.01
What could be causing this?
If it helps, I am not using any navBar

using swift GSKStretchyHeaderView with nib

I'm having problems using a GSKStretchyHeaderView associated with a nib file that exposes IBOutlet property.
I'm getting this error when I try to load the nib:
`let nibViews = NSBundle.mainBundle().loadNibNamed("GSKNibStretchyHeaderView", owner: self, options: nil)

setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key backgroundImageView.`

could you see if you can reproduce it, an eventually add it to the Example project.

Thanks for this library

How to use Twitter Style

Hi,

I have implemented GSKStretchyHeaderView to my swift project by using cocoapods.

I couldn't find any information about how to set as Twitter style header view.
Is there any information about that ?

Thanks

NSInternalInconsistencyException when observe contentOffset

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x16018be00 of class ArticleDetailTableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x16139d720> (
<NSKeyValueObservance 0x16139d6f0: Observer: 0x161392750, Key path: contentOffset, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x15fe19b40>
)'
*** First throw call stack:
(0x182342db0 0x1819a7f80 0x182342cf8 0x182c96d80 0x1819c1ae8 0x1822209fc 0x1822f6bc0 0x182220c50 0x183b08088 0x18750e088 0x10025abec 0x181dbe8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

I always got this error. This happen when tableview removed from superview.

Any idea to solve this error?

Bad Calculation for UICollectionView

There is a bug when you use this library for a collectionView:
Steps for replicate the bug:

  1. Create a collection view.
  2. Set the property: sectionHeadersPinToVisibleBounds = YES. (for the UICollectionViewFlowLayout)
  3. Add a header for any section.
  4. Configure the strechy subclass like this:
    header.minimumContentHeight = 64
    header.maximumContentHeight = 200
    header.expansionMode = GSKStretchyHeaderViewExpansionMode.topOnly
    header.contentShrinks = true
    header.contentExpands = true
    header.contentAnchor = GSKStretchyHeaderViewContentAnchor.top
  5. Run the app and you will see that the section header pins to the maximumContentHeight but the sticky header could be minimized at that moment. So that's the issue.

Attach you will find an screenshot.
(PS: The header is located in section 1, not in section 0, so this collection view has:
3 rows in section 0
1 header in section 1
5 rows in section 1)
img_3622

Issue when using with UITableView section header view

Hello @gskbyte,

Thank you for the awesome library! :)

I am having an issue when using this library with an UITableView that has sections and sections header views. The problem is that, as we already know, UITableView section header views are sticky, and the remain on the top when scrolling, but when using them with GSKStretchyHeaderView, they never reach the top, instead, they are stuck at the maximumContentHeight distance from the top.

Do you have any workaround for this issue? I was reading through the already closed issues here, and some users reported a similar problem (#5), but the solution suggested there did not work for me.

I have noticed that a similar solution is included in your example project:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    UIEdgeInsets scrollViewContentInset = scrollView.contentInset;
    if (scrollView.contentOffset.y > -self.stretchyHeaderViewMinimumContentHeight) {
        scrollViewContentInset.top = self.stretchyHeaderViewMinimumContentHeight;
    } else if (scrollView.contentOffset.y < -self.stretchyHeaderViewMaximumContentHeight) {
        scrollViewContentInset.top = self.stretchyHeaderViewMaximumContentHeight;
    } else {
        scrollViewContentInset.top = -scrollView.contentOffset.y;
    }
    scrollView.contentInset = scrollViewContentInset;
}

but there is a problem with this workaround - when you scroll back, the UITableView does not scroll smoothly. Feel free to check it out, the same applies for the example project.

I would really appreciate you assistance in solving this.

Thanks in advance, and keep up the good work!

Question About Collection View

Hey @gskbyte your library is really great. I am trying to use it on a swift project and i noticed something really weird. I have a collection view in which i add a custom view. My custom view contains an imageView. When i try to load an image asynchronously to the imageView nothing is happening. I mean my image view is not updated. If i initialise my image view with an image everything works properly, you can see the image. Do you have anything in your mind?

Header content above cells...

Hey, thanks for great work.

I'm trying to achieve the following:
image

We wish for the green 'share' button to float above content.
However it seems the view hierarchy doesn't allow this as the header sits below cells.

So far only able to achieve this:
image

Perhaps this is impossible & I need to add the share button as it's own subview to the table view.
However, I wonder if you had any suggestions?

Twitter-Like Header: doesn't snap back

We have implemented a header view based pretty much exactly off the Twitter-like example. The main difference is that we centered the UserImage View and made it larger. We also added an additional field below the description field you had. So some pretty minor layout changes.

It looks great when the view first loads. However, (only after) I scroll through a page of data in the view and THEN scroll back to the top, when the top scrolls to the full size again. the header background image stays extremely large, and forces all the fields below it to compress and clip.

Why would this be happening?

Example image attached.

gsk-header-example

Sorry for the blurs. (Customer data)

Swift Support

How to use this library with Swift?

When i'm trying to import GSKStretchyHeaderView it throws me error

Sections on tableview

Hi there. Great work.

Ever tried using the library, using tableview headers? I'm having trouble with it.
tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

The set header seems to stays in the original tableview Y

aug-22-2016 12-47-39

Any suggestion?

Thx

Add Animation when change maximumHeightContent?

Hi sir, as my issue title. Can I normally add some animation when changing maximumHeightContent?
I try to put my change height code into UIView animate block but nothing happend.
Thanks

Do not expand header when bouncing scrollview at the bottom

Is there a way to not expand the header when I bounce the collection/table/scroll view at the bottom?

I am using a XIB file for the header in the same way as the example app. Same problem happens there when you scroll all the way to the bottom.

Carthage

Hello,

Can you please support Carthage?

Thanks

move avatar from center to top left of header

Hi,

I would like to thank you for this library, in second example we have avatar in the middle (centerX) what is the calculation If I want to move smoothly this avatar from the middle to top left of the header view while scrolling ..

Your support is highly appreciated

Regards

Using GSKStretchyHeaderView with UIViewController

Hi gskbyte,

I'm currently working on a project in swift trying to use GSKStretchyHeaderView. Instead of a tableview or collectionview, I want to use a UIViewController instead. Do you know if there is any easy way of doing this?

Improvement: Add refresh control

Hey @gskbyte,

Thank you for the awesome work with your StretchyHeaderView, way to go!

I have a suggestion. Is it possible to add a refresh control when pulling the table view/scroll view/collection view?

Thanks in advance,
Nikola

Extra padding space in my tableView

Hi, I've been using this library since the time I discovered this, until now. However, now I am experiencing an annoying problem. I am putting a custom view which has a map inside in my stretchyHeader, and my tableView is having an extra space. When I use the Debug View Hierarchy feature of Xcode, I can see that the extra space is called UITableViewWrapper. See the screenshots.

screen shot 2017-04-19 at 4 27 04 pm

screen shot 2017-04-19 at 4 27 13 pm

So... how to remove this one? Or what's causing this? Similar question from SO: http://stackoverflow.com/questions/18880341/why-is-there-extra-padding-at-the-top-of-my-uitableview-with-style-uitableviewst

However, no answer worked and I believe this is caused by the library.

Tap on headerView or tableview the header view collapse .

when I tap anywhere on the screen i.e. on the tableview cell or header view . the header view collapse . I want that it only collapse when I scroll the tableview or header view . please help to find the solution.

with regards
Akash Jacob

Need Suggestion

Team,

Want to use UIPaginationViewController instead of UISegmentControl in "GSKTwitterStretchyHeaderView" Can we do that, Need exactly same Same Twitter Profile View now we have. How can we achieve that. Any Ideas/Suggestions.

Static table headers have gap with top of table

When I add GSKStretchyHeaderView to a static table view, headers not stick to the top and they have gap with size of the maximum stretchy header to the top.

    headerView = Bundle.main.loadNibNamed("HeaderView", owner: self, options: nil)![0] as? UIView
        
    let hView = GSKStretchyHeaderView(frame: CGRect(x: 0 ,y:0 ,width: self.view.frame.size.width ,height:self.view.frame.size.width * 2 / 3))
    hView.addSubview(headerView!)
    hView.minimumContentHeight = 64
    hView.maximumContentHeight = 250
        

    self.tableView.addSubview(hView)

and here is my sticky header

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        if  section == 1 {
            self.viewHeaderPrice.backgroundColor = UIColor.red
            return self.viewHeaderPrice
        }
        return super.tableView(tableView, viewForHeaderInSection: section)
    }
    
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        if  section == 1 {
            return self.viewHeaderPrice.height
        }
        return 0
    }

You can see the red header (Section 1) remains in the middle of screen with scroll

photo

constraints problem

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint: 0x15df97b0> (null) ((null), (null))",
"<NSAutoresizingMaskLayoutConstraint: 0x15df97e0> H:[GSKStretchyHeaderContentView:0x15eebf10(375)](%28null%29, %28null%29)",
"<NSAutoresizingMaskLayoutConstraint: 0x15df34b0> H:[GSKStretchyHeaderView:0x15d55520(320)](%28null%29, %28null%29)",
"<NSLayoutConstraint: 0x15ee9630> H:[UIView:0x15d5bff0]-(0)-| ((null), (null))",
"<NSLayoutConstraint: 0x15eebba0> (null) ((null), (null))"
)

Stretchy header view only compresses if table content size big enough

Hey, I have setup a starchy header view. This header is min height 64 and max height 140. I am using it as a replacement for the navigation bar. I have noticed though that the bar will only compress to its min size if the table content view size is big enough to force it to scroll enough. So if my table only has one cell or so it's not big enough to scroll. Am I doing something wrong here?

UITableView Moves Down when UIKeyboard

Hello, thanks for this awesome control!
But I have a problem (could be represented in your Example app). If I have an UITextField inside custom subclass of GSKStretchyHeaderView. When UITextField becomes first responder - the table view moves down (The initial State is
2017-01-09 11 16 11
after I press -
2017-01-09 11 16 19
). Thanks in advance.

App crashes when removing GSKStretchyHeaderView from superview

When I try to remove StretchyHeaderView from table view, app crashes. StretchyHeaderView .stopObservingScrollView function is called two times (on didMoveToSuperview and willMoveToWindow:).
Removing KVC observer that is no longer an observer makes app crashing.

issue with UITableView style plain and sections

Hi,
how I use the library with a UITableView with style plain and sections?

I have a table with sections and scrolling not works properly: the first section row must follows the top anchor indeed it remains blocked in the initial position altougth table scrolling (see screenshoot).
Moreover the section row view passes in front of stretchheaderview and navigation bar.
I cant figured out if is a bug o is the standard bheavior with tableview and sections.

I have added few screens to explain better.
thank you

Startup: ok -> section in right place
https://slack-files.com/T0EV6LREK-F0R6K9SUW-60649597dd

Scrolling: top section must follows top anchor scrolling
https://slack-files.com/T0EV6LREK-F0R6FEZ7X-ff50bb9e91

Scrolling: section over stretchview/navbar
https://slack-files.com/T0EV6LREK-F0R66E2F2-483513ebed

UIRefreshControl in wrong position

First: Amazing control. Really encompasses a whole bunch of functionality that I needed. Thank you.

I'm having an issue where my tableView's refreshControl (1) appears behind my header view and (2) is positioned incorrectly.

1 was solved by calling bringSubviewToFront on the refreshControl. But 2 is a bit trickier. I suspect that the issue is related to the adjustment of the maximumContentHeight var, which is something that changes in my app based on the presence (or lack of) of some content. I've tried removing the refreshControl and then adding it back to the tableView after each height adjustment, but that doesn't seem to work. I'm also aware that the position of the UIRefreshControl is in alignment with the tableView's top inset; which I'm adjusting to work appropriately with the tableView section headers.

I tried searching through archived issues related to UIRefreshControl, but didn't find one that was answered properly.

#18
#52

If you have any ideas, I'd be grateful for any insight. Ty :)

Header covers table view while cell is animating

Hi! Great work! I noticed something weird and haven't quite figured out a solution yet. I subclassed GSKStretchyHeaderView and added it to my table view. Everything works great but the header always covers table view cells during cell's animation (to be more specific, this is the table view animation I'm using: https://github.com/Ramotion/folding-cell). This only happens when header's height is smaller than its max height(aka, when scrolled up). It looks like this issue #5 but I'm not sure what exactly is causing this problem. Any ideas?

HeaderView not visible

I implemented this functionality on table view. i outlet my header view and map it with GSKStretchyHeaderView and add as a subview on table view.

When we go to view controller header not visible then i scroll table view then header visible and invisible. i am using auto layout in header view.

can you tell me what is the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.