Frames and Bounds - Scroll View School - Learning iOS from the Ground Up!

  Рет қаралды 2,640

Kodeco

Kodeco

5 жыл бұрын

Scroll views are built on the concept of frames and bounds. In this video, you'll get an overview of frames and bounds and how scroll views use them to give us that scrolling behavior that we all love.
About the Course:
Scroll views are a means to provide a lot of content in a small amount of space, but unfortunately, they can be a bit tricky. This course will walk you through the basics of scroll views, showing you to use them in a variety of layouts. Once you get comfortable with them, you'll explore several scroll view recipes that have been inspired in some popular recipes.
View the complete course over here:
www.raywenderlich.com/9223-sc...
---
About www.raywenderlich.com:
raywenderlich.com is a website focused on developing high quality programming tutorials. Our goal is to take the coolest and most challenging topics and make them easy for everyone to learn - so we can all make amazing apps.
We are also focused on developing a strong community. Our goal is to help each other reach our dreams through friendship and cooperation. As you can see below, a bunch of us have joined forces to make this happen: authors, editors, subject matter experts, app reviewers, and most importantly our amazing readers!
---
UIScrollView is the superclass of several UIKit classes including UITableView and UITextView.
The central notion of a UIScrollView object (or, simply, a scroll view) is that it is a view whose origin is adjustable over the content view. It clips the content to its frame, which generally (but not necessarily) coincides with that of the application’s main window. A scroll view tracks the movements of fingers and adjusts the origin accordingly. The view that is showing its content “through” the scroll view draws that portion of itself based on the new origin, which is pinned to an offset in the content view. The scroll view itself does no drawing except for displaying vertical and horizontal scroll indicators. The scroll view must know the size of the content view so it knows when to stop scrolling; by default, it “bounces” back when scrolling exceeds the bounds of the content.
The object that manages the drawing of content displayed in a scroll view should tile the content’s subviews so that no view exceeds the size of the screen. As users scroll in the scroll view, this object should add and remove subviews as necessary.
Because a scroll view has no scroll bars, it must know whether a touch signals an intent to scroll versus an intent to track a subview in the content. To make this determination, it temporarily intercepts a touch-down event by starting a timer and, before the timer fires, seeing if the touching finger makes any movement. If the timer fires without a significant change in position, the scroll view sends tracking events to the touched subview of the content view. If the user then drags their finger far enough before the timer elapses, the scroll view cancels any tracking in the subview and performs the scrolling itself. Subclasses can override the touchesShouldBegin(_:with:in:), isPagingEnabled, and touchesShouldCancel(in:) methods (which are called by the scroll view) to affect how the scroll view handles scrolling gestures.
A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.
The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZooming(in:) and scrollViewDidEndZooming(_:with:atScale:); in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.
State Preservation
If you assign a value to this view’s restorationIdentifier property, it attempts to preserve its scrolling-related information between app launches. Specifically, the values of the zoomScale, contentInset, and contentOffset properties are preserved. During restoration, the scroll view restores these values so that the content appears scrolled to the same position as before. For more information about how state preservation and restoration works, see App Programming Guide for iOS.

Пікірлер: 4
@stealthnoodle12
@stealthnoodle12 4 жыл бұрын
Upvote for that Mike Myers haircut. Also, great video 👏
@akath22
@akath22 2 жыл бұрын
Can you imagine these two going at it?
@siouxdesign
@siouxdesign 5 жыл бұрын
In Bounds 'positive Y is up' so shouldn't the bounds coordinates be -50 +40 at 1:21 ?
@darkMakubeX
@darkMakubeX 5 жыл бұрын
This is what i'm confused as well. Or instead of moving up to the left, it should be "down to the left" following the new origin mentioned. -50, -40 .. hope someone can clear this up.
Frames vs Bounds - Beginning Scroll Views in iOS
9:11
Kodeco
Рет қаралды 10 М.
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 6 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 38 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 23 МЛН
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 27 МЛН
Frame & Bounds | SWIFT
11:42
Swift Magic
Рет қаралды 3,1 М.
Understanding UIScrollViews
9:04
Swift Arcade
Рет қаралды 724
LayoutSubviews vs layoutIfNeeded (Swift 5)
17:56
SwiftBook
Рет қаралды 13 М.
Мок-собеседование iOS разработчика
1:17:34
iOS Такой • IOS Разработка • IT Подкасты
Рет қаралды 10 М.
Super Power Scroll Views - SwiftUI - iOS 17
9:14
Sean Allen
Рет қаралды 25 М.
Swift Access Control Explained
9:44
Sean Allen
Рет қаралды 33 М.
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 6 МЛН