Set clicked button index when dismissing due to app going to background
Add support for iOS 6