Popular IOS (8) UI-Himalayan UI implementation-Use of UIScrollView, ios-uiscrollview

Source: Internet
Author: User

Popular IOS (8) UI-Himalayan UI implementation-Use of UIScrollView, ios-uiscrollview

CAT/CAT sharing, must be excellent
Material address: http://blog.csdn.net/u013357243/article/details/44588251
Address: http://blog.csdn.net/u013357243/article/details/44588159

First view results




Controls used by storyBoard


Code Implementation
/* Create an iOS communication learning group: 304570962 ps: The Articles of cats and cats have been reproduced in many places. I'm flattered, but please turn around a little bit when switching. Don't leave the materials or anything, it's okay if you don't mark and repost it. You will be very happy if you work hard together to learn about cats and cats. If you need to learn more about materials and video materials, you can add cat QQ: 1764541256 or znycat. Let's study hard together. The current function of this game has been achieved, although some code extraction is not so perfect Original: http://blog.csdn.net/u013357243? Viewmode = contents * // NYViewController. m // 05-Himalayan // Created by apple on 15-3-24. // Copyright (c) 2015 znycat. all rights reserved. // # import "NYViewController. h "@ interface NYViewController () @ property (weak, nonatomic) IBOutlet UIScrollView * scrollView; @ property (weak, nonatomic) IBOutlet UIButton * lastButton; @ end @ implementation NYViewController/** the Main. after the storyboard The setScrollView method is automatically called by the system. In the stack proxy, the blue ones are called by ourselves, while the others are system ones. */-(Void) setScrollView :( UIScrollView *) the first sentence in scrollView {// set method is assigned _ scrollView = scrollView;/** set the scroll View content 1. If there is currently a spacing, automatically adjust contentOffset 2 according to the spacing. If there is no spacing, contentOffset is) in short, contentSize will adjust the offset contentInset according to the margin and will not adjust the offset * // set the spacing (specify the content's outer margin, and will not automatically adjust it according to contentOffset) self. scrollView. contentInset = UIEdgeInsetsMake (64, 0, 49, 0); // set the content of the scrolling view self. scrollView. contentSize = CGSizeMake (0, CGRectGetMaxY (self. lastButton. frame); NSLog (@ "% s" ,__ func __); // modify contentOffset/** if the spacing is set first and then the content of the scroll view is set, you do not need to control and modify contentOffset. This is a shortcoming of Apple's design and the coupling is too strong, pay attention to code loading and downloading * // self. scrollView. contentOffset = CGPointMake (0,-64);} // After the view is loaded, run-(void) viewDidLoad {[super viewDidLoad]; NSLog (@ "% s ", __func _);} @ end
UIScrollView usage and attributes
The screen size of a mobile device is extremely limited, so the content displayed directly in front of the mobile user is quite limited. When there are many content displayed, when a screen is exceeded, the volume user can use the scroll gesture to view the content outside the screen. The normal UIView does not have the scroll function and cannot display too much content, UIScrollView is a view control that can be rolled. It can be used to display a large amount of contents in the display, and all contents can be viewed through rolling.

Example: "Settings" and other examples on the ghost mobile phone

If UIScrollView rollback cannot be rolled, it may be due to the following reasons:
ContentSize is not set for Pipeline
Required scrollEnabled = NO
The consumer did not receive the touch event: userInteractionEnabled = NO
The autolayout function has not been canceled for rolling. (If you have added the scroll sub-Control of ScrollView to the Storyboard, you must cancel autolayout to scroll the scrollView)

Common attributes

@ Property (nonatomic) CGPointcontentOffset; // This attribute struct is used to indicate the scroll position of UIScrollView. @ property (nonatomic) CGSizecontentSize; // This attribute is used to indicate the size of UIScrollView content, and the rolling range (how far can it be rolled) @ property (nonatomic) UIEdgeInsetscontentInset; // This attribute can add additional scrolling areas in the four weeks of UIScrollView
Common attribute Image Representation

Original Directory: http://blog.csdn.net/u013357243? Viewmode = contents

Ps: the process of learning iOS is a process of reading code and writing code. Although most of them are currently using the UI, the UI is very important. This is what the customer sees at first glance, is the face of our app, just like we look at people, they all look at the face first, so we need to make the UI beautiful.
Ps: A friend asked the cat and CAT, saying that many of them directly use code to load the UI. Why do they use storyboard for disconnection.
In fact, there are several reasons. For example, some small programs can be dragged directly, which is not so troublesome at all. The code is mainly used for later maintenance convenience, and the storyboard allows us to see the effect of facts, it is conducive to learning.

PS, of course, code writing is still very important. (In fact, I prefer to write all the code.) The feeling that code controls the world is amazing, but learning is a gradual process. Let's study hard together.

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.