Skip to main content

#iOS8 #XCode6 #SizeClasses



       In Xcode 6, new feature called "Size classes" have been introduced. The size classes are used for making the storyboard compatible for all iOS Devices(iPhone & iPad, even iPod) in both portrait as well as Landscape orientations.

To set the size class:

1) Choose "Universal" option while creating the project.
2) Check the auto layout checkbox in Main.storyboard -> File Inspector -> "Use Auto Layout"
3) Check the size classes check box in Main.storyboard -> File Inspector -> "Use Size Classes".

There are two types of size classes:
Regular and Compact.

Hence the different configurations(screen sizes) include,
1) wAny hAny - Base configuration
2) wCompact hRegular - iPhone Portrait
3) wCompact hCompact - iPhone Landscape
4) wRegular wAny - iPad Landscape and portrait

On selecting the base configuration, the storyboard works the same in all devices. This can be viewed in "preview" option in the assistant editor on selecting the main.storyboard.

On selecting other configurations, the layout of the corresponding device changes based on the specifications set in that configuration.


To set the constraints by default, select the particular view( it may be label, image view or anything) and click the "Resolve Autolayout Issues" icon in the storyboard. Then, choose "Add missing constraints" which will add the necessary constraints needed for the auto layout.


IMAGE SIZES:

Also, three size resolution of images - 1x,2x,3x need to be added.

Create different versions of image in "asset catalog" and add the three images.

Comments

Popular posts from this blog

Running Database Fetch (Core Data) in Background Thread using magical Record

   To run database fetching in background thread(in a separate context), so that the UI does not get blocked: __block NSMutableArray *dataArray= [[NSMutableArray alloc] init];   // Create a child context of the main context   NSManagedObjectContext *privateContext = [NSManagedObjectContext MR_context];   // When using private contexts execute the core data code in it's private queue using performBlock: or performBlockAndWait:   [privateContext performBlock:^{     // Execute fetch   NSArray *privateObjects;   if(entity_predicate == nil) {       //fetch all! duh!       privateObjects = [self MR_findAllSortedBy:sort_key ascending:YES inContext:privateContext];     } else {       privateObjects = [self MR_findAllSortedBy:sort_key ascending:YES withPredicate:entity_predicate inContext:privateContext];   ...

Container View - Multiple View Controllers

       By default, Each Container View can have one child view controller only. Only one controller can be added to container using "Embed segue".       In order to add multiple view controller,  the following may help:      Use a separate container view controller and add it using embed segue to the container view. Now from the container view controller that is created, perform transition to different child view controllers using custom segues.

Percent Escape the reserved Characters in URI

URI encoding need to be done when performing network API calls based on RFC 3986. In order to encode any character, the following native method can be used: [uriString stringByAddingPercentEncodingWithAllowedCharacters : [ NSCharacterSet URLQueryAllowedCharacterSet ] ] But the above method is not compliant with RFC3986 and it does not encode the reserved characters like "!*'();:@&=+$,/?%#[]". Hence, the following method can be used for percent encoding the specific reserved characters. ((NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef) string, NULL,  CFSTR("!*'();:@&=+$,/?%#[]"), encoding))); }