Creating Circular and Infinite UIScrollViews
来源:互联网 发布:小志网络赚钱博客 编辑:程序博客网 时间:2024/05/22 17:47
I‘ve just finished implementing theinfitine scroll for me. In my Implementation I have UITableViewCellwith a scrollView and Navigationbuttons. The scrollView contains xviews all with the same width. views are alined horizontally andpaging is enabled.
scrollView.clipsToBounds =YES;
scrollView.scrollEnabled =YES;
scrollView.pagingEnabled =YES;
scrollView.showsHorizontalScrollInd
My codelogic is like thefollowing:
In my initialization functionI
create all the views (for thescrollview) and
put them into an array and
add them to the scrollView
Then I call a function that calculatesin a loop the positions for each view (each time you detect ascroll this function will need to be called too). It always takesthe first element of the array and sets the frame to (0,0,...,...),the second with (i*width,0,....,....) and so on. The functionbeeing called looks like this:
-(void)updateOffsetsOfViews{
}
Then (still in the initializationprocess) I add an observer
[scrollView addObserver:selfforKeyPath:@"contentOffset" options:0 context:nil];
so each time something in thescrollView changes I get the (observeValueForKeyPath)-functioncalled, which looks like this:
-(void)observeValueForKeyPath:(NSString *)keyPathofObject:(id)object
{
}
And in dealloc or viewDidUnload(depends on how you implement it) don't forget to remove theobserver.
[scrollView removeObserver:selfforKeyPath:@"contentOffset"];
Hope this helps, you might notice someoverhead, but in my implementation I also support like scrolling 5pages (well... unlimited) at once and autoanimated scrolling etc.so you might see something that could be thrown away.
- Creating Circular and Infinite UIScrollViews
- Creating and invoking MXML
- Using and Creating Builds
- Creating Lists and Cards
- Creating and Concatenating Matrices
- android wearable-Creating Cards and Creating Lists
- Circular linked list and Josephus ring
- ZZULIOJ 1768 Lovely Circular And Linear
- 【郑轻】[1768]Lovely Circular And Linear
- Creating And Playing With Branches
- Creating, Applying, and Submitting Patches
- Creating Mutable and Immutable StringObjects
- Creating and Editing File Templates
- Creating and Editing Live Templates
- Creating and Editing Template Variables
- 21 Running and Creating Executables
- Infinite Mixture Models with Nonparametric Bayes and the Dirichlet Process
- Infinite size of Hypothesis set and growth funciton
- 优化UITableView性能
- IOS PNG OR JPG
- 利用预渲染加速iOS设备的图像显示
- 从NIB加载时属性为空的问题
- 折磨人的两个小问题[IOS]
- Creating Circular and Infinite UIScrollViews
- UITableView backgroud on Ipad
- 解决Xcode4.xOrganizer SVN "Unable to load revisions”
- Objective-c中@class和#import
- 如何对iOS5项目中的特定文件关闭ARC
- UITabBarController with none selected controller
- iphone中按Home键退出程序
- c++ 构造函数中explicit关键字的作用
- performSelector:withObject:afterDelay: