RungeZhai / SeamlessCyclicScrollView

Infinitely Cyclic Scrolling Demo With a UICollectionView
MIT License
44 stars 6 forks source link

Question about previewing cells #2

Open tundsdev opened 9 years ago

tundsdev commented 9 years ago

Is there a way of implementing the cells so the cell stays in the middle but the cell on the left and right are previews half way similar to this news cartel extra high

RungeZhai commented 9 years ago

Do you mean a pageEnabled UIScrollView but the pageWidth is smaller than the UIScrollView's frame? Actually you can and there are more than one solution. The simplest way I think is using a UICollectionView and implementing the UIScrollView delegate method scrollViewWillEndDragging: withVelocity:targetContentOffset: to manually calculate the destination offset so that the collectionView appears to be pageEnabled.

sourav13 commented 8 years ago

Question about converting your code to swift , the method scrollviewDidScroll () doesn't reach ahead after first if , always returns from there for me , your code works perfectly fine i have downloaded and checked it , Can you help me find where i'm going wrong. Here is the link to the same https://bitbucket.org/sourav13/infinitehorizontalscrolling. Please help me convert it into swift.

RungeZhai commented 8 years ago

@sourav13, Sorry, been a little busy. I will have a look and reply ASAP.

RungeZhai commented 8 years ago

@sourav13 It seems that Swift doesn't support function level static variable. The lastcontentOffsetX in scrollViewDidScroll has to be an outer scope variable. So the solution is

  1. declare a property for MainViewController var lastcontentOffsetX = CGFloat(FLT_MIN)
  2. use this property instead of the local variable lastcontentOffsetX in scrollViewDidScroll
sourav13 commented 8 years ago

@RungeZhai , Thank you for your precious time , your suggestion worked out for me.