2
votes

I have got an issue with the UIAlertController over iOS9... it was good over ios8, but now it give me the next result: Action Sheet issue

It's work fine with Alert style, but with the ActionSheet style it works strange, and drops the following error:

Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "=10)]>", "", "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2015-10-09 16:41:29.613 OnskeskyenShareExtension[53993:14714610] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "=12)-[UIView:0x7f8f69cde5e0] (Names: '|':_UIAlertControllerActionView:0x7f8f69cddec0 )>", "", "", "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

My code is:

func createActionPicker(){
            self.alertController = UIAlertController(title: "", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet);
            self.alertController.modalInPopover = false;
            for i in 0...self.listData.count-1{
                let action = UIAlertAction(title: self.listData[i], style: .Default, handler: {(alertAction:UIAlertAction) in
                    self.dropDownListText.text = alertAction.title;
                    for j in 0...self.alertController.actions.count-1{
                        if(alertAction.isEqual(self.alertController.actions[j])){
                            self.selectedIndex = j;
                            break;
                        }
                    }
                });
                self.alertController.addAction(action);
            }
            self.alertController.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil));
            let alertView = UIView(frame: self.frame);
            self.addSubview(alertView)
    }

public func dropDown(sender:UIView)
{
    if(self.listData.count == 0) {return}
    if(UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad)
    {
        self.popover.presentPopoverFromRect(self.dropDownButton.frame, inView: self, permittedArrowDirections: UIPopoverArrowDirection.Right, animated: true);
    }

    if(UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone)
    {
        dispatch_async(dispatch_get_main_queue(), {
            self.viewController.presentViewController(self.alertController, animated: true, completion: nil);
        });
    }
}

Anyone could help me to solve this annoying issue?!

1
did you get solution for this? I am struggling since 2 days.Sanoj

1 Answers

-1
votes

You can try this:

let refreshAlert = UIAlertController(title: "", message: "your message here", preferredStyle: UIAlertControllerStyle.ActionSheet)

refreshAlert.addAction(UIAlertAction(title: "Clear message history", style: .Destructive, handler: { (action: UIAlertAction!) in
}))

refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction!) in
}))

presentViewController(refreshAlert, animated: true, completion: nil)

it works perfectly for me on iOS9