开发者

How to create a simple view controller whose view bounces like a table view

开发者 https://www.devze.com 2023-03-26 06:53 出处:网络
What is the simple way to create UIViewController with view in it with some controls, that 开发者_Python百科will bounce like it was big UITableViewCell in UITableView?

What is the simple way to create UIViewController with view in it with some controls, that 开发者_Python百科will bounce like it was big UITableViewCell in UITableView ?

By bouncing, I mean if user moves his finger up and down the view will move like it was a UITableView.

Thanks.


I think you're looking to use a UIScrollView.

The way to accomplish this is to set the contentSize equal to the frame's size, and then set the bounces property to YES.

Something like this assuming you're working in the context of a UIViewController:

CGSize size = CGSizeMake(320, 460);
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[scrollView setBounces:YES];
[scrollView setContentSize:size];
[[self view] addSubview:scrollView];
[scrollView release];

//add subviews to scrollView...


Have a look at UIScrollView. It will help you. UITableView itself is a subclass of UIScrollView

0

精彩评论

暂无评论...
验证码 换一张
取 消