Skip to main content

Understanding of Size Classes?

Size Classes are an abstraction of how a device should be categorized depending on its screen dimensions. Apple defined two categorizations for both vertical and horizontal sizes called “Regular” and “Compact”. The former specifies a big space, while the latter specifies a small” space. How big or small exactly? Here, “big” and “small” are not intended to be measured in inches.

iOS Size Classes

Apple has introduced many devices like iPhone, iPad with different screen sizes and resolution. Also after iOS 8 apple has supported multitasking in iPad. So for the developers to develop a common or single UI for all the devices apple has introduced the concept of an adaptive layout by combining auto layout and size classes.

What is adaptive layout:

The adaptive layout is a method of building the apps based on the size and characteristics of the container instead of a targeting a particular device. We can create a single layout to work on all devices instead of writing a platform specific code. Adaptive layout includes size classes and trait collection etc.
Before size, a class has been introduced developers were using following approaches to developing the UI.
-Universal storyboards. Unique storyboard for iPhone and iPad.
-Monitoring the orientation change API for dynamic layout during device rotation.
-Using layout constraints to manage different size within single device class.
To avoid these apple has introduced size classes after iOS8.

About Size classes:

Size class identifies relative amount of display space for the height and width or vertically and horizontally. Size class categorizes each dimension into two terms.

– Compact: As the name indicates, if the container space is small to display the content then it is called as compact.
– Regular: If there is enough space in the container to display the content then this is called as Regular.
Using the size class, one can retrieve the general information about the device in its current orientation.


Size classes for different devices:



Default Size Classes for Different Devices
Table : Size classes for devices with different screen sizes.
Device
Portrait
Landscape
iPad (all)
iPad Mini
Vertical size class: Regular
Horizontal size class: Regular
Vertical size class: Regular
Horizontal size class: Regular
iPhone 6 Plus
Vertical size class: Regular
Horizontal size class: Compact
Vertical size class: Compact
Horizontal size class: Regular
iPhone 6
Vertical size class: Regular
Horizontal size class: Compact
Vertical size class: Compact
Horizontal size class: Compact
iPhone 5s
iPhone 5c
iPhone 5
Vertical size class: Regular
Horizontal size class: Compact
Vertical size class: Compact
Horizontal size class: Compact
iPhone 4s
Vertical size class: Regular
Horizontal size class: Compact
Vertical size class: Compact
Horizontal size class: Compact

IMPORTANT
Never assume that your app will be displayed with a specific size class on a device. Always check the size class found in an object’s trait collection when making decisions about how to configure that object.


Comments

Popular posts from this blog

SQLite 3 Procedure & Functions

SQLite 3 Procedure & Functions iOS - SQLite Database SQLite can be used in iOS for handling data. It uses sqlite queries, which makes it easier for those who know SQL. Steps Involved Step 1.  Create a simple  View based application . Step 2.  Select your project file, then select targets and then add  libsqlite3.dylib  library in choose frameworks. Step 3.  Create a new file by selecting File-> New -> File... -> select  Objective C class  and click next. Step 4.  Name the class as  DBManager  with  "sub class of"  as NSObject. Step 5.  Select create. Step 6.  Update  DBManager.h  as follows − SQLite 3 Functions Preview sqlite3_open : This function is used to create and open a database file. It accepts two parameters, where the first one is the database file name, and the second a handler to the database. If the file does n...

The differences between Core Data and a Database

Database Core Data Primary function is storing and fetching data Primary function is graph management (although reading and writing to disk is an important supporting feature) Operates on data stored on disk (or minimally and incrementally loaded) Operates on objects stored in memory (although they can be lazily loaded from disk) Stores "dumb" data Works with fully-fledged objects that self-manage a lot of their behavior and can be subclassed and customized for further behaviors Can be transactional, thread-safe, multi-user Non-transactional, single threaded, single user (unless you create an entire abstraction around Core Data which provides these things) Can drop tables and edit data without loading into memory Only operates in memory Perpetually saved to disk (and often crash resilient) Requires a save process Can be slow to create millions of new rows Can create millions of new objects in-memory very quickly (although saving these objects will be slow) Offer...