Use of iOS UIScrollView proxy and several methods of listening in the scaling age

Source: Internet
Author: User

Use of iOS UIScrollView proxy and several methods of listening in the scaling age

There must be at least three steps:

I. Implementation Protocol

2. Establish relationships

3. Set the scaling range

For details, see the code:

 

# Import "ViewController. h" @ interface ViewController ()
 
  
// Comply with this Protocol First @ property (weak, nonatomic) IBOutlet UIScrollView * ScrollView; @ property (weak, nonatomic) IBOutlet UIImageView * minionPic; @ end @ implementation ViewController // This method is always called during the rolling process-(void) scrollViewDidScroll :( UIScrollView *) scrollView {// NSLog (@ "scrollViewDidScroll ");} // call this method when you start to scroll. When you drag it once, this method is called only once and is called once at the beginning-(void) scrollViewWillBeginDragging :( UIScrollView *) scrollView {// NSLog (@ "scrollViewWillBeg InDragging ");} // the event to be triggered when a user starts scaling actions-(void) scrollViewWillBeginZooming :( UIScrollView *) scrollView withView :( UIView *) view {NSLog (@ "scrollViewWillBeginZooming");} // which View should be set to bloom when the user scales? -(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView {return self. minionPic;}-(void) viewDidLoad {[super viewDidLoad]; // set the content size of ScrollView contentSize self. scrollView. contentSize = self. minionPic. frame. size; // bind a proxy to establish the relationship between the ScrollView and proxy self. scrollView. delegate = self; // you can specify the zooming range as self. scrollView. minimumZoomScale = 0.2; self. scrollView. maximumZoomScale = 2.0; // Do any additional setup after loading the view, typically from a nib .} -(void) didReceiveMemoryWarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .} @ end
 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.