CooperRS / RMPickerViewController

This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner
MIT License
381 stars 51 forks source link

Picker options show in simulator, but not on a device #19

Closed raysarebest closed 7 years ago

raysarebest commented 9 years ago

I'm making an app in Swift, and when invoking my instance of RMPickerViewController in the simulator, all goes well, but when I run it on my iPhone 5s on iOS 8.1.1 (built with the iOS 8.2 SDK), none of the options in the picker show, and I'm left with a blank square

CooperRS commented 9 years ago

Are you using the black version of RMPickerViewController?

raysarebest commented 9 years ago

I'm setting the blurEffectStyle to .Dark, if that's what you mean

CooperRS commented 9 years ago

Yes, that is what I mean.

That's a bug on Apples side. The simulator supports tint colors for the UIDatePicker and UIPickerView while the real devices don't. I already submitted a bug report to Apple (It`s No. 18040667 if you want to reference it).

hdoria commented 9 years ago

Any workaround for this?

hdoria commented 9 years ago

Just found a solution. You need to use this method from the delegate:

- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component;

Example:

- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    NSString *title = @"Picker Value";
    NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

return attString;

}

With Swift:

func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
    let string = "Picker Value"
    return NSAttributedString(string: myString, attributes: [NSForegroundColorAttributeName:UIColor.whiteColor()])
}
CooperRS commented 9 years ago

Yes, that maybe a working workaround for RMPickerViewController :)

Does not help for RMDateSelectionViewController though, which basically has the same problem in the dark version :/...

liseven commented 8 years ago

it has a bug that content of the pickerView dose not show like something white on it when it is running on swift2.2 xcode7.3 iOS 9.3 .

Alifar commented 8 years ago

Same here since iOS 9.3, and I have it on ExtraLight. Is there a workaround for this? I don't necessary need the blur effect if that is what causing the problem. Thanks!

AkshayDegada commented 8 years ago

i was facing same issue, i have resolved it with help of @NipulDaki - by change 1 line coding, i given solution to below

At Creation of RMPickerViewController object.

RMPickerViewController *pickerVC = [RMPickerViewController pickerController]; [RMPickerViewController setLocalizedTitleForSelectButton:@"Done"];

* pickerVC.disableBlurEffects=YES; * <-- add this like in your code and RMPickerViewController work without affecting any thing.

NipulDaki commented 8 years ago

Thanks AkshayDegada it work perfectly on iOS 9.3

Alifar commented 8 years ago

@AkshayDegada GREAT!! You saved the day!

ahmad-atef-zz commented 8 years ago

@AkshayDegada Thanks a lot :)

CooperRS commented 7 years ago

This problem should be solved somewhere in between iOS 9 and 10.1.1. It is not present in iOS 10.1.1 anymore :). However, for supporting older versions of iOS, the above workaround should be used.