-1

I am creating a UIActionSheet using the Swift programming language with SDK8.1 targeting iOS7.0+. The below code shows my action sheet creation:

//Opens action sheet for image selection
    @IBAction func showActionSheet(){
        if(UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
            if(images.count >= Numbers.LIMIT_IMAGES){
                lblError.displayMessage(FAUErrorLabel.MessageLevel.INFO, message: Messages.MAXIMAGES)
            }
            else{
                var actionSheet = UIActionSheet(title: "Choose a Picture Method", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Gallery", "Take Photo")
                actionSheet.showInView(self.view)
            }
        }
        else{
            lblError.displayMessage(FAUErrorLabel.MessageLevel.ERROR, message: Messages.NOCAMERA)
        }
    }

However, it displays as if there is a cancel button and another single button, which is a combination of the two "otherButtonTitles". The "Take Photo" button is not touchable. In iOS8.0, there is a separation between the two buttons and the "Take Photo" button is touchable.

iOS7.1 enter image description here

iOS8.1 enter image description here

How do I get the two buttons to both be touchable in iOS7.1?

Thanks!

steventnorris
  • 5,656
  • 23
  • 93
  • 174
  • don't get it -- there are 3 buttons in both screenshots, no? – Daij-Djan Dec 17 '14 at 18:48
  • yep, looks and works fine. – A-Live Dec 17 '14 at 19:02
  • @Daij-Djan The first screen shot has no seperation between the two buttons in ios7.1 and the second button "Take Photo" cannot be clicked. It has no user interaction. Only gallery and cancel can be selected. – steventnorris Dec 17 '14 at 19:48
  • I don't think it's your problem, but you should terminate the `otherButtonTitles` list with nil, otherwise you risk crashes when the destination routine walks off the end of the parameter list. – David Berry Dec 17 '14 at 20:03
  • @David in Swift, terminating with a nil yields an error "Type 'String' does not conform to protocol 'NilLiteralConvertible'. I'm fairly certain that's an Obj-C requirement only. – steventnorris Dec 17 '14 at 20:08

1 Answers1

0

I was using a tab bar but presenting from a view, causing the tab bar to hide the bottom button from user action, although it did not hide it visual. Using the below line instead of displaying from view fixed the problem. This appears to be a iOS7.1 bug, as it does not occur in iOS8.1.

actionSheet.showFromTabBar(self.tabBarController?.tabBar)
steventnorris
  • 5,656
  • 23
  • 93
  • 174