uipickerview

How can I get images to appear in UI PickerView Component in Swift?

安稳与你 提交于 2019-11-30 06:33:53
问题 I am trying to use images in a Swift PickerView. I don't know how to get the images to actually appear in the component. I know how to do this using Strings with the titleForRow function but I don't know how to do this using images. Here is my code so far: import UIKit class ViewController: UIViewController, UIPickerViewDelegate { @IBOutlet weak var pickerView: UIPickerView! var imageArray: [UIImage] = [UIImage(named: "washington.jpg")!, UIImage(named: "berlin.jpg")!, UIImage(named: "beijing

How to change the Font size in UIPickerView?

混江龙づ霸主 提交于 2019-11-30 06:18:46
问题 I have one UIPickerView. This is having nearly 200 items, each items has long texts, so, i want to resize the UIPickerView's font size. How can i change it? It is possible? Can any one help me? Thanks ! Yuva.M 回答1: You need to implement pickerView:viewForRow:forComponent:reusingView: method in picker's delegate - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* tView = (UILabel*)view; if (!tView){

how to add UIPickerView in UIActionSheet

早过忘川 提交于 2019-11-30 05:38:12
问题 i'm having task to enter rating(1 - 5) value, so i found the below code for date picker, can anyone help me to alter below code so to add UIPickerView to choose rate from 1 to 5 UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Ratings" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil]; UIDatePicker *pickerView = [[UIDatePicker alloc] init]; pickerView.datePickerMode = UIDatePickerModeDate; [menu addSubview:pickerView]; [menu showInView

Bottom pop-up UIPicker?

浪尽此生 提交于 2019-11-30 04:07:38
Is the UIPicker that pops up from the bottom of the screen when an action is called just a basic UIPickerView that is coordinated in a certain way? (Like a UIActionSheet?) How would I implement that? Here's animation code, that I use: - (void)animateDatePicker:(BOOL)show { CGRect screenRect = self.frame; CGSize pickerSize = [self.datePickerView sizeThatFits:CGSizeZero]; CGRect startRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height, pickerSize.width, pickerSize.height); CGRect pickerRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height - pickerSize.height,

How can I animate displaying UIPickerView after pressing button?

纵然是瞬间 提交于 2019-11-30 04:02:54
I want to animate my UIPickerView after pressing the button. I already have coded my UIPickerView to be hidden on viewDidLoad and not hidden after pressing a button, but it doesn't animate like how a ModalViewController animates by default. I just want my UIPickerView to be animated just like a ModalViewController animates by default. I've researched already on the site, and on the web, but I can't seem to do it properly. Here's my code: #pragma mark - Picker View - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } - (NSInteger)pickerView:(UIPickerView *

ios programming - Data argument not used by format string

与世无争的帅哥 提交于 2019-11-30 03:51:48
问题 I get a Data argument not used by format string error when I run the following code: - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSString *colour = ([colourArray objectAtIndex:row]); NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:(colour) forKey:@"colour"]; NSLog(@"NSString =", colour); NSLog(@"NSUserDefaults =", [defaults objectForKey:@"colour"]); } I get the error on both NSLog lines.

Center UIPickerView Text

梦想与她 提交于 2019-11-30 03:10:42
So I have a uipickerview with rows that only contain the number 0-24 and it looks a bit silly since the numbers are left aligned leaving a huge gap on the right of the pickerview. Is there an easy way to center align text in a uipickerview? - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)]; label.text = [NSString stringWithFormat:@"something here"]; label.textAlignment = NSTextAlignmentCenter; //Changed to NS as UI is deprecated.

Invalid context error on iOS 7 when adding a UIPickerView inside a UIActionSheet?

萝らか妹 提交于 2019-11-30 03:04:14
问题 I have an UIPickerView inside an UIActionSheet and have done that in a way suggested by many others here at SO: Add UIPickerView & a Button in Action sheet - How? how to add UIPickerView in UIActionSheet The solutions have worked fine until now when testing my app on iOS 7. It still works but I got a lot of "invalid context 0x0" warnings during runtime in Xcode. The errors are coming with a nice message too: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This

UITextView and UIPickerView with its own UIToolbar

大城市里の小女人 提交于 2019-11-30 01:39:20
I like to replicate the form behavior of Safari on the iPhone in my own app. If you enter data in an web form you get a separate UIToolbar (previous, next, done) just above the UIKeyboardView. Same for choosing an option: you get the same UIToolbar just above an UIPickerView. I am looking for demos / sourcode / ideas how to implement this. Would I create my own subview with that toolbar and textview / pickerview? Is there a more elegant way? Especially something that leverages becomeFirstResponder of UITextfield? So i created a UIViewCOntroller subclass to manage this. on that i wrote this

Does UIPickerView's selectRow:inComponent:animated: call pickerView:didSelectRow:inComponent:?

纵饮孤独 提交于 2019-11-30 01:18:14
问题 Does UIPickerView's selectRow:inComponent:animated: call pickerView:didSelectRow:inComponent: ? Otherwise, can I just call it myself? Thanks 回答1: You do have to call it manually and you do it though the delegate. // In this example the UIPickerView object is in a property ... self.pickerView.datasource = self; self.pickerView.delegate = self; // Selects the row in the specified component [self.pickerView selectRow:0 inComponent:0 animated:NO]; // Manually calls pickerView:didSelectRow