Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 10 custom cancel and done buttons do not appear #376

Closed
Maxatma opened this issue Jan 22, 2018 · 3 comments
Closed

iOS 10 custom cancel and done buttons do not appear #376

Maxatma opened this issue Jan 22, 2018 · 3 comments

Comments

@Maxatma
Copy link

Maxatma commented Jan 22, 2018

screen shot 2018-01-22 at 6 00 36 pm

@Maxatma
Copy link
Author

Maxatma commented Jan 22, 2018

I guess, the problem is similar to
#350
#362
But the only one described solution isn't useful, coz toolbar in AbstractActionSheetPicker already has [pickerToolbar layoutIfNeeded];

@Maxatma
Copy link
Author

Maxatma commented Jan 22, 2018


final class KZActionSheetDatePicker: ActionSheetDatePicker {
    var kzdoneButton: UIButton!
    var kzcancelButton: UIButton!
    var kzdoneItem: UIBarButtonItem!
    var kzcancelItem: UIBarButtonItem!
    
    convenience init(title: String!,
                     datePickerMode: UIDatePickerMode,
                     selectedDate: Date!,
                     origin view: UIView!) {
        
       self.init(title: title,
                  datePickerMode: datePickerMode,
                  selectedDate: selectedDate,
                  doneBlock: nil,
                  cancel: nil,
                  origin: view)
        
        kzdoneButton = UIButton(type: .custom)
        kzdoneButton.setTitle("OK", for: .normal)
        kzdoneButton.setTitleColor(.red, for: .normal)
        
        kzcancelButton = UIButton(type: .custom)
        kzcancelButton.setTitle("Cancel", for: .normal)
        kzcancelButton.setTitleColor(.red, for: .normal)
        
         kzdoneItem = UIBarButtonItem(customView: kzdoneButton)
         kzcancelItem = UIBarButtonItem(customView: kzcancelButton)
        
        setDoneButton(kzdoneItem)
        setCancelButton(kzcancelItem)
    }
}

class ViewController: UIViewController {
    
    var picker: KZActionSheetDatePicker!
    
    override func viewDidLoad() {
        
        picker = KZActionSheetDatePicker(title: "Select me",
                                         datePickerMode: .date,
                                         selectedDate: Date(),
                                         origin: self.view)
        
        picker.show()
        
        
        super.viewDidLoad()
    }
}

@Maxatma
Copy link
Author

Maxatma commented Jan 22, 2018

Well, I don't know if that is expected behavior or not, just worked it around by initializing buttons with frame manually:
kzdoneButton = UIButton(frame: CGRect(x: 0, y: 0, width: 100, height: 35))
It works fine on both 10 and 11 iOS
Hope this workaround could help somebody.

@Maxatma Maxatma closed this as completed Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant