UIActionsheet does not display all buttons on iPad with iOS7

UIActionSheet instances do not display correctly on iPads running iOS7. For some reason, they display a cancel button and leave the last button. The same code works fine on iOS8.

You expected the cancel button to be ignored, given that tapping elsewhere on the screen will close the action sheet. Does anyone know why this is so?

Exactly the same code is used in both cases:

// Create UIActionSheet    
let mapOptions = UIActionSheet(title: "Select map type", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Standard", "Hybrid", "Satellite")

// Display from bar button
mapOptions.showFromBarButtonItem(self.mapTypeButton, animated: true)

comparison of UIActionSheet instances on iOS 7 and 8

+4
source share
2 answers

, UIActionSheet . - , ​​ - .

// Create the UIActionSheet
var mapOptions = UIActionSheet()
mapOptions.title = "Select map type"
mapOptions.addButtonWithTitle("Standard")
mapOptions.addButtonWithTitle("Hybrid")
mapOptions.addButtonWithTitle("Satellite")

// Add a cancel button, and set the button index at the same time
mapOptions.cancelButtonIndex = mapOptions.addButtonWithTitle("Cancel")
mapOptions.delegate = self

// Display the action sheet
mapOptions.showFromBarButtonItem(self.mapTypeButton, animated: true)
+5

Swift. . , init ( nil), .

let mapOptions = UIActionSheet(title: "Select map type", delegate: self, cancelButtonTitle: nil, destructiveButtonTitle: nil, otherButtonTitles: "Standard", "Hybrid", "Satellite")

mapOptions.cancelButtonIndex = mapOptions.addButtonWithTitle("Cancel")

( , , .)

+3

All Articles