How can I use UIScrollView
? please give me a simple example with one scrolling image?
问题:
回答1:
This will get you an insight of the UIScrollView
control:
Learning the basics of UIScrollView
Referenced from UIScrollView Tutorials
Some good samples with the basic functionalities covered
- http://halmueller.wordpress.com/2008/10/08/a-very-simple-uiscrollview-demo/
- http://developer.apple.com/iphone/library/samplecode/Scrolling/index.html
- http://www.vimeo.com/1642150
- http://jonathanwatmough.com/2008/12/implementing-tap-to-zoom-in-uiscrollview-on-an-iphone/
- http://cocoawithlove.com/2009/01/multiple-virtual-pages-in-uiscrollview.html
Not to mention:
- https://stackoverflow.com/search?q=UIScrollView
回答2:
This can be one example. Basically we create a scrollview, set its frame, add content as a subview, and then set the content size. The image (iphone.png) below is bigger than the iphone screen so that we can scroll it.
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iphone.png"]];
[scrollView addSubview:imageView];
[imageView release];
scrollView.contentSize = CGSizeMake(imageView.image.size.width, imageView.image.size.height);
[window addSubview:scrollView];
[scrollView release];
回答3:
Have a look at Apple's example apps:
- Scrolling
- PhotoScroller
- ScrollViewSuite
And of course at Apple's official documentation:
- Scroll View Programming Guide for iOS
回答4:
Try this link for scrollview
http://www.devx.com/wireless/Article/45113/1954
回答5:
Here is a link for all good tutorials: Code link
This link explain you basic steps for how to use: Steps link
This is a example of scrollview with one scrolling image using XIB and just few lines of code: scrollview with xib
Thanks
回答6:
You can use below code to add UIScrollView on yourView :-
[self.ScrollView setContentSize:(CGSizeMake(self.view.frame.size.width, self.view.frame.size.height))];
Step:1 Create a UiScrollView,
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *MyScrollView;
@end
Step2: In your ViewController.m,
[self.MyScrollView setContentSize:(CGSizeMake(self.view.frame.size.width, self.view.frame.size.height))];
回答7:
Add UIImageView in to UIScrollView.
then,
Use
imageView.image = [UIImage imageNamed:@"image1.png"];
imageView.frame = CGRectMake(0.0, 0.0, imageView.image.size.width, imageView.image.size.height);
scrollView.contentSize = CGSizeMake(imageView.image.size.width, imageView.image.size.height);