vowed21 / HWViewPager

ViewPager for iOS : UICollectionView
MIT License
86 stars 15 forks source link

Not Working on iPhone 6 and above! #4

Open yasirtahir opened 8 years ago

yasirtahir commented 8 years ago

Hi,

Well, I have implemented your code in my application which is SWIFT based app. It is working perfectly fine on iPhone 4s, 5, and 5s. But when I am trying to run it on iPhone 6, or above, it is not working perfectly fine. Suppose if there are three items in the collection, and when I try to scroll to the second one, it will skip the second and moved directly to the third one. Similarly, If I try to get back to the second one, It will move directly to the first one.

In short, In a single to and fourth movement, the middle item is always skipped.

Can you please guide me accordingly?

vowed21 commented 8 years ago

please, use "HWSwiftyViewPager"

https://github.com/vowed21/HWSwiftyViewPager

poojaagarwal1331 commented 7 years ago

Hello, I have used the same which you have mentioned https://github.com/vowed21/HWSwiftyViewPager but still I am facing the issue on every device i.e., the middle item is always skipped.

Can you please guide me accordingly?

Pratik-Sodha commented 6 years ago

To Solve above issue implement <UICollectionViewDelegateFlowLayout> in HWViewPager.m file.

@interface HWViewPager() <UICollectionViewDelegate,UICollectionViewDelegateFlowLayout> .....

And implement following methods.

-(CGSize)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout )collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewFlowLayout flow = (UICollectionViewFlowLayout) collectionView.collectionViewLayout;
    CGFloat widthNew = collectionView.frame.size.width - (flow.sectionInset.left *2) - flow.minimumLineSpacing;
    CGFloat heightNew = collectionView.frame.size.height - flow.sectionInset.top - flow.sectionInset.bottom;
    return CGSizeMake(widthNew, heightNew);
}

Thank you