The Uiscrollview class provides support for displaying the view size of content larger than the application window. It enables users to scroll through the content in a light sweep gesture, zooming in and out of the view by hand-pinching gestures.
Paging
When there are multiple views in the frame, you do not want to drag the interface to stop in the middle of the connection position, you need paging function
CGRect screenrect =
[Self.window bounds];
CGRect bigrect = screenrect;
BigRect.size.width *= 2.0;
Initialize ScrollView
Uiscrollview *scrollview = [Uiscrollview alloc] initwithframe:screenrect];
[Self.window Addsubview:scrollview];
Creates a custom view object and adds it to the ScrollView
myview *view = [MyView alloc] initwithframe:screenrect];
[ScrollView Addsubview:view];
Creates another object that is just outside the screen, screenrect.origin.x = screenRect.size.width on the right side of the previous view
;
MyView *anotherview = [MyView alloc] initwithframe:screenrect];
[ScrollView Addsubview:anotherview];
Complete the basic settings, there are two properties in the Uiscrollview, Contentsize and Pagingenabled, the former determines the scope of the Uiscrollview, the latter is to set whether the system automatically paging
[ScrollView setContentSize:bigRect.size];
[ScrollView Setpagingenabled:yes];
Scaling
Assuming you have a view member in this application, you want to achieve his zoom out function
CGRect screenrect = [Self.window bounds];
Initialize the ScrollView and set its zoom scale to implement the delegate
uiscrollview *scrollview = [Uiscrollview alloc] initwithframe:screenrect];
[ScrollView setminimumzoomscale:1.0];
[ScrollView setmaximumzoomscale:5.0];
[ScrollView setdelegate:self];
[Self.window Addsubview:scrollview];
Initialize member
MyView = [MyView alloc] initwithframe:screenrect];
For this scrolling view to implement scaling, you need to adhere to the Uiscrollviewdelegate protocol, and then implement the Delegate method
-(UIView *)
Viewforzoominginscrollview: (Uiscrollview *) ScrollView
{return
myview;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/