UIView controls greyed out in iOS7

When opening and closing sheets and popovers in iOS7 the ui-controls like UISegmentedControl, UIProgressView, etc.
Its in the Apple's native app as well, where the bar button items become greyed, or conversely, they no longer turn to grey once a popover/viewcontroller shows up.

Its an open bug in iOS7, for quick fix we can manually set tintAdjustmentMode property of the effected UIView to UIViewTintAdjustmentModeNormal, e.g;
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(x, y, width, height)];
segmentedControl.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

NOTE: This will prevent the color toggling in any case, i.e; there will be no effect of dimming when opening Popover/Sheet/ViewController

Handoff in iOS8

Handoff is all about making you work across all devices within proximity range. It uses BTLE (Bluetooth low energy or Bluetooth LE ) and iCloud account to pair devices. After pairing in iOS it display the current app icon in left corner of the lock screen, left side of home screen in multitasking switcher screen, On Mac it shows in right part of the dock and command + tab menu

Handoff supports live streaming between apps in two devices. Handoff works in between websites and apps as well.

Fundamental unit of handoff is an Activity (NSUserActivity). When we create an Activity it automatically brodcasts and shows up in paired devices. When user selects the Activity (i.e; select the app) the host is informed and asked for the detaled information, after that host sends the detailed package and the app get launched.

All applications from the same developer can exchange activities this is based on the team identifier. Applications don't have to claim;
  • the same activity type they create
  • any activity types, but can still create them
This is helpful when there are multiple apps in iOS for an app in OSX

Creating, Updating and Continuing Activity is supported by AppKit and UIKit, i.e; UIDocument, UIResponder now have a NSUserActivity property. In UIDocument based apps the activity is set in .plist and will be managed by OS itself. In UIResponder, when the app is in focus UIKit walks the view hierarchy and check for the Activity. Every time user focus the Activity it evokes the becomeCurrent method and invalidate when it finished. To manage user, Activity have userInfo property for minimal ammont of information. It is a dictonary and can store NSArray, NSData, NSDate, NSDictonary, NSNull, NSNumber, NSSet, NSString, NSUUID, NSURL..

UIApplicationDelegate have new method (i.e; application:continueUserActivity:restorationHandler:) which tells the delegate that the data for continuing an activity is available. This method have a optional block, restorationHandler which executes if your app creates or fetches objects to perform the task it must be called from the app’s main thread. restorationHandler has no return value and take restorableObjects as param which is an array of UIResponder or UIDocument objects representing objects you created or fetched in order to perform the operation.

When continued from another device NSUserActivityDelegate call userActivityWasContinued: which notifies the delegate that the user activity was continued on another device. This will helpful when more then two devices are paired and Handoff on the same app.


Extensions in iOS - Keynote

  1. Not all but most of the APIs are available for extesions
  2. Extensions have separate container for them which means they act like a saperate app for there parent app
  3. Extensions don't have access to their parent app data but can opt into data sharing
  4. Apps and Extensions can use a shared container/storage area which can be accessed at same time with the help of;
    • NSFileCordination - provides general syns strategy for app and extension
    • CoreData
    • sqilite
    • NSUserDefaults - with a shared suite name
    • Shared Keychains - for an app group
  5. Once user approve the Privacy access (e.g; Photos, Location..) to an app all its extensions don't need to ask saperately
  6. Extensions are stateless that means they are killed aggressively


Extensions configuration keys in .plist
  • NSExtension - A dictionary of keys and values that describe an app extension
    • NSExtensionPointIdentifier - Extension point’s reverse DNS name PFB
    • NSExtensionPrincipalClass - The name of the principal view controller class created by the template
    • NSExtensionAttributes - A dictionary of extension point–specific attributes that specify aspects of an app extension
      • further configuration based on extension kind


Values for the NSExtensionPointIdentifier key based on extension type;
  • Action Extension - com.apple.ui-services
  • Custom Keyboard Extension - com.apple.keyboard-service
  • Document Picker Extension - com.apple.fileprovider-ui
  • File Provider Extension - com.apple.fileprovider-nonui
  • Finder Sync Extension - com.apple.FinderSync
  • Photo Editing Extension - com.apple.photo-editing
  • Share Extension - com.apple.share-services
  • Today Extension - com.apple.widget-extension

View Controllers in iOS 8 - A quick review

High level changes

Traits replaced UIViewController methods and properties for interface orientation PFB
UIAlertController replaced UIActionSheet and UIAlertView
UISearchController replaced UISearchDisplayController
UIUserNotificationSettings replaced UIApplication methods and properties for registering notifications, supported register the types of alerts local or push notifications with some custom actions apart from remote notifications
UISplitViewController supported on iPhone as well as iPad with new collapsed property PFB
UINavigationController added options to condensing and hiding PFB
UIPresentationController provides advanced view and transition management for presented view controllers PFB
UIPrinterPickerController view controller-based way to display a list of printers
UIPopoverPresentationController manages the display of content in a popover


Methods for showing view controller are changed to;
  1. showViewController: sender: - replacement for all showing view controller methods
  2. showDetailViewController: sender: - its implimented by split view controller
and these are implemented by all custom view controllers as well.

Previously we used to differentiate orientation with UIInterfaceOrientation and UIUserInterfaceIdiom, in iOS 8 insteed of this there is a new concept of Size Classes. Size Classes have four different variations based on Vertical, Horizontal, Regular and Compact ie;
  1. Horizontal Regular - iPad landscape, iPhone portrait
  2. Horizontal Compact - iPhone landscape
  3. Vertical Regular - iPad portrait
  4. Vertical Compact - iPhone portrait, iPhone landscape
An iPad have regular size classes only.

Traits and Trait collections

Traits are the bunch of properties that we can use to determine how the layout of your application should change as its environment changes. It is consist of following properties;
  • Horizontal size class - Regular / Compact
  • Vertical size class - Regular / Compact
  • User interface idiom - iPhone / iPad / iPod Touch
  • Display scale - 1.0 / 2.0
These properties can be "Unspecified" in such case when a UIView is not in the view hierarchy or we have specified a custom Trait Collection. We can also customize the Trait Collection of a child view with Appearance Proxy. Trait Collections (a.k.a UITraitCollection) vended from trait container have both a horizontal and vertical size class trait, it used to describe a collection of traits assigned to an object.

All these Traits and its values are wrapped in a container i.e; Trait Collections. Trait Environments of a child are inherited from its parent because of this we can access Trait Environments till root from any child. We can get change notification with traitCollectionDidChange: method and override it in UIView and UIViewController subclasses to react to a trait change.

Trait Environments (a.k.a UITraitEnvironment) is a protocol which provides access to a view collection’s traits (object.traitCollection) and a way to track changes in the trait collection ([object traitCollectionDidChange:]). Its confirmed by most of the objects in view hierarchy i.e; Screen > Window > View Controller(s) > View(s) UIViewController adopts traits and the new sizing techniques for adjusting the view controller’s content. Traits are consist of Size Class, Display Scale and Idiom for a particular view object. Size Class coarsely defines the space available and categorizes available space horizontally and vertically.

Trait Collection are also implemented in UIImage so that we can provide image for any size rather then 1x and 2x versions using Assets Catalog. UIImage view automatically picks the write image based on its Trait Collection, this will be usefull in such case when we need saperate image with respect to varity of size classes.

We can also add multiple Trait Collection with the help of traitCollectionWithTraitsFromCollections:, on addition the unspecified Traits are filled by the specified and for multiple specified Traits, the last one will be picked.

UIViewController also have new methods which helps Parent View Controller to override the traits for a child, i.e;
  • -(void)setOverrideTraitCollection: forChildViewController:
  • -(UITraitCollection *)overrideTraitCollectionForChildViewController:


Split View Controller

UISplitViewController is by default collapsed for horizontally compact container (e.g; iPhone, iPod Touch..) otherwise they are expended, the same can be changed further. We can also adjust the % width of both partitions a UISplitViewController.

Good to know: We can also track split view controller expand/collapse with UIViewControllerShowDetailTargetDidChangeNotification in NSNotificationCenter

Navigation Controller Condensing

There are several awaited features are implimented in UINavigationController, auto and manual toggling nav bar i.e;
  • navController.hideBarOnTap - to enable auto toggle hide/show on tapping
  • navController.condensesBarOnSwiped - to enable safari like auto condensing bars
  • navController.hidesBarWhenVerticallyCompact - to enable auto hides bar for vertically mode
  • navController.condensesBarsWhenKeyboardAppears - to enable auto condensing bars when keyboard appears
  • navController.navugationBarCondensed - to manually toggle nav bar


Presentation Controllers

Presentation Controller enhance the exesting API for creating custom presentation, all presentation styles now have an associated Presentation Controller with them. Some new presentation styles are introduced as well, i.e;
  • UIModelPresentationOverFullscreen - shown like an overlay which means it don't remove the presenting view controller
  • UIModelPresentationOverCurrentContext - cover upon the presenting view controller only
  • UIModelPresentationPopover - it is more like a popover itself
Now most of the iPad-only styles are avilable in iPhone as well, some of them are in full screen mode (for iPhone) by default but configurable to be non-full screen.

Presentation Controllers can easily adapt to size class change. We can use Adaptive Presentations (a.k.a UIAdaptivePresentationControllerDelegate) to track the presentation orientation change. We can create custom presentation controllers which will adapt if shouldPresentInFullscreen returns YES.

Transition Coordinators (a.k.a UIViewControllerTransitionCoordinator) are part of the UIViewController adaptive UI story. During an active view controller transition, use Transition Coordinator to respond to user cancelation of the transition to run a custom animation or register a completion handler. UIContentContainer can help you to adapt the contents of your view controllers to size and trait changes. New methods are added to it to provide support for Trait, i.e;
  1. -(void)willTransictionToTraitCollection:withTransitionCoordinator: -
  2. -(void)viewWillTransitionToSize:withTransitionCoordinator: -


UIScreen is now interface oriented, which means;
  • -[UIScreen bounds] are interface-oriented
  • -[UIScreen applicationFrame] are interface-oriented
  • Status bar frame notification are interface-oriented
  • Keyboard frame notification are interface-oriented
To still work in fixed cordinate system we can use protocol UICordinateSpace

New in Interface Builder

  • We can use same Storyboard/XIB for any screen size of all iOS devices like iPhone4S, iPhone5, iPad..
  • We can deploy backwards to iOS 6 and iOS 7
  • We can preview devices, orientation and OS versions. Go to Jump Bar > Preview Assistance > Chose plus button from bottom to select device and desired orientation
  • We can to use Auto Layout to design flexible UI
  • We can remove or add unique Auto Layout constraints for each screen size
  • We can use Assets Catalog for images to use different versions of same image based on size
  • We can override subviews for specific size class