Search Results

Search found 85 results on 4 pages for 'uipickerview'.

Page 1/4 | 1 2 3 4  | Next Page >

  • Customizing UIPickerView in xcode

    - by Srinivas G
    Hi, I developed an application which consists of UIPickerView....It displays as default size in height of the UIPickerView.I want to display the UIPickerView as 320x480 size(iphone simulator size)..so the whole screen has the picker view without using transorm property,because it will stretched the whole view....its not looking good...even with selection indicator also stretched...I need not stretchable picker view..but need to show the picker view with the whole screen..We can control the width of the UIPickerView..But how can we control the height of the UIPickerView..... Thanks & Regards...

    Read the article

  • How to detect changes on UIPickerView ?

    - by tristaf
    I want to detect changes of UIPickerView value. If UIPickerView respond to addTarget i used a code like this: -(void) valueChange:(id)sender { change = YES; } UIPickerView *questionPicker = [[UIPickerView alloc] init]; [questionPicker addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventValueChanged]; How can i do same things but in a correct way ? Thanks

    Read the article

  • Code to show UIPickerview under clicked UITextField

    - by Chris F
    I thought I'd share a code snippet where I show a UIPickerView when you click a UITextField. The code uses a UIPickerView, but there's no reason to use a different view controller, like a UITableViewController that uses a table instead of a picker. Just create a single-view project with a nib, and add a UITextField to the view and make you connections in IB. // .h file #import @interface MyPickerViewViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, UITextFieldDelegate> - (IBAction)dismissPickerView:(id)sender; @end // .m file #import "MyPickerViewViewController.h" @interface MyPickerViewViewController () { UIPickerView *_pv; NSArray *_array; IBOutlet __weak UITextField *_tf; BOOL _pickerViewShown; } @end @implementation MyPickerViewViewController - (void)viewDidLoad { [super viewDidLoad]; _pickerViewShown = NO; _array = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", nil]; _pv = [[UIPickerView alloc] initWithFrame:CGRectZero]; _pv.showsSelectionIndicator = YES; _pv.dataSource = self; _pv.delegate = self; _tf.delegate = self; _tf.inputView = _pv; } - (IBAction)dismissPickerView:(id)sender { [_pv removeFromSuperview]; [_tf.inputView removeFromSuperview]; [_tf resignFirstResponder]; _pickerViewShown = NO; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { if (!_pickerViewShown) { [self setRectForPickerViewRelativeToTextField:textField]; [self.view addSubview:_tf.inputView]; _pickerViewShown = YES; } else { [self dismissPickerView:self]; } return NO; } - (void)setRectForPickerViewRelativeToTextField:(UITextField*)textField { CGFloat xPos = textField.frame.origin.x; CGFloat yPos = textField.frame.origin.y; CGFloat width = textField.frame.size.width; CGFloat height = textField.frame.size.height; CGFloat pvHeight = _pv.frame.size.height; CGRect pvRect = CGRectMake(xPos, yPos+height, width, pvHeight); _pv.frame = pvRect; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [_array objectAtIndex:row]; } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return _array.count; } - (void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { _tf.text = [_array objectAtIndex:row]; [self dismissPickerView:self]; } @end

    Read the article

  • Hiding/ Showing UIPickerView

    - by aahrens
    I Have an a touchesEnded event that checks for when a UITextField is pressed. What I would like it to do is is hide/show a UIPickerView. How can this be done? - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; if (CGRectContainsPoint([self.textField frame], [touch locationInView:self.view])) { NSString * error = @"Touched the TextField"; UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Selection!" message:error delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; //Want to show or hide UIPickerView } } I already have an allocated UIPickerView when touches occur @interface ThirdViewController : UIViewController <UITextFieldDelegate,UIPickerViewDelegate> { IBOutlet UIPickerView *pickerView; }

    Read the article

  • UIPickerView and empty core data array

    - by Mark
    I have a viewcontroller showing items from a core data entity. I also have a tableview listing records from the same entity. The table is editable, and the user could remove all the records. When this happens, the view controller holding the pickerview bombs because it's looking for records in an empty array. How to prevent this? I'm assuming I need to do something different at objectAtIndex:row... # pragma mark PickerView Section - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; // returns the number of columns to display. } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [profiles count]; // returns the number of rows } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { // Display the profiles we've fetched on the picker Profiles *prof = [profiles objectAtIndex:row]; return prof.profilename; } //If the user chooses from the pickerview - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { selectedProfile = [[profiles objectAtIndex:row]valueForKey:@"profilename"]; }

    Read the article

  • Load CoreData objects' string property into UIPickerView

    - by OscarTheGrouch
    Hello Currently I have an entity named "Events" in a CoreData app. "Events" has one string property named "eventName". In the -(void)viewDidLoad I am trying to Fetch all the "Events" objects and load their "eventName" by alphabetical order into a UIPickerView. The ultimate end goal is through the use of a textField, buttons and the pickerView being add new objects in and remove unwanted objects out. Basically turning the UIPickerView into a UITableView. Currently I am able to save objects to the CoreData store, but am not able to pull them/their properties out into the UIPickerView. I am willing and able to share the project source code to anyone who wants it, or is willing to look at it to help out. thanks Chris

    Read the article

  • Select row After UIPickerView is loaded

    - by Steve Gibson
    I have an iphone database app that loads a UIPickerView with data from a table. I want to set the selected row to a particular row from the data in another table. for example: Lets say I have a UIPickerView that is loaded with X number of names of the iPhone users friends (the number of names is variable, could be 1 or 1000 and all are entered into the DB by the user). The iPhone user has a preference set that their current best friend is TED. I want the UIPickerView to be position to TED when displayed. Where do I call selectRow? I tried in viewDidAppear but it was never called, in titleForRow which caused all kinds of strange behavior. viewDidLoad and viewWillAppear are out of the question because I don't know what's in the datasource to the picker yet. Thanks in advance.

    Read the article

  • Unselected UIPickerView value

    - by morticae
    According to the documentation, if a UIPickerView has no selected value, the expected return from selectedRowInComponent: should be: "A zero-indexed number identifying the selected row, or -1 if no row is selected." However, if I check the value the very line after initializing one, its value is 0. Even if I then manually set it to -1, it still returns 0. I would like to be able to detect whether the user has chosen a value yet or not, without recording it in a local variable. Is this possible? example: UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 46.0, 320.0, 216.0)]; [picker selectRow:-1 inComponent:0 animated:NO]; NSLog(@"SELECTED %d", [picker selectedRowInComponent:0]); expected output: SELECTED -1 actual output: SELECTED 0

    Read the article

  • issue of hide uipickerview in iphone

    - by M007
    I want to display UIPickerView with UIToolBar on the top of pickerView with done and cancel button.Attached is the screen shot for the same.I also have tab bar controller in bottom side of view and I want to display pickerView over bottom bar thats why I am using uipickerView inside of actionsheet.Now my issue is how to dismiss that pickerView on cancelButton click which is added in UIActionSheet? Following is the function to display pickerView : -(IBAction)setMile:(id)sender { menu = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; // Add the picker UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,55,0,0)]; pickerView.delegate = self; pickerView.showsSelectionIndicator = YES; // note this is default to NO UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)]; pickerToolbar.barStyle = UIBarStyleBlackOpaque; [pickerToolbar sizeToFit]; NSMutableArray *barItems = [[NSMutableArray alloc] init]; UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(setMileCancel:)]; [barItems addObject:cancelBtn]; [cancelBtn release]; cancelBtn=nil; UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; [barItems addObject:flexSpace]; [flexSpace release]; flexSpace=nil; UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(setMileDone:)]; [barItems addObject:doneBtn]; [doneBtn release]; doneBtn=nil; [pickerToolbar setItems:barItems animated:YES]; [barItems release]; barItems=nil; [menu addSubview:pickerToolbar]; [menu addSubview:pickerView]; [menu showInView:self.view]; //[menu showFromTabBar:[[self tabBarController] tabBar]]; this code is not working [menu setBounds:CGRectMake(0,0,320, 545)]; [pickerView release]; [menu release]; pickerView=nil; menu=nil; } I have following code on cancel button click -(IBAction)setMileCancel:(id)sender { //[menu removeFromSuperview]; [menu dismissWithClickedButtonIndex:0 animated:YES]; }

    Read the article

  • UITextField to show UIPickerView in xcode 4.3.2 using textField.inputView

    - by ChromeBlue
    I'm looking to have a UITextField display a UIPickerView when touched. I found quite a few questions on the same topic that say to use UITextField.inputView. However, when I try, nothing changes. I have a very simple code: setupViewController.h #import <UIKit/UIKit.h> extern NSString *setupRightChannel; @interface setupViewController : UIViewController { UITextField* rightChannelField; UIPickerView *channelPicker; } @property (retain, nonatomic) IBOutlet UITextField* rightChannelField; @property (retain, readwrite) IBOutlet UIPickerView *channelPicker; setupViewController.m #import "setupViewController.h" @Interface setupViewController() @end @implementation setupViewController @synthesize rightChannelField; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"Setup"; // Do any additional setup after loading the view from its nib. rightChannelField.inputView = channelPicker; } -(IBAction)okClicked:(id)sender { setupRightChannel = rightChannelField.text; } I feel like I might be missing something fundamental here, but I honestly cannot think of what it is.

    Read the article

  • UIPickerView selectedRowInComponent: returns stale data after code adjusts it

    - by Eric Lloyd
    I have a UIPickerView with multiple components. Some values are grayed out, and my pickerView:didSelectRow:inComponent honors this by shifting the picker component in question to the nearest valid value, much as UIDatePicker moves from "30" to "28" when you select "February". Then it calls a delegate method to announce the adjusted value. When my adjuster method calls my UIPickerView's selectRow:inComponent:animated:YES, the value on screen is correct, but the values from selectedRowInComponent: are stale (from before the adjustment for gray values). However, if I call selectRow:inComponent:animated:NO, the returned values are correct, but the lack of animation is jarring. I've tried wrapping the adjustment in a beginAnimations:/commitAnimations block and catching the values in UIView's +animationDidStopSelector, but I still get stale values. Has anyone run into this before?

    Read the article

  • Customizing UIPickerView

    - by Raj
    Hi all, I have a requirement where UIPickerView should be customized. The picker view should look something like this: The application which has customized the pickerView similarly is: http://itunes.apple.com/us/app/convert-the-unit-calculator/id325758140?mt=8 I have tried removing the default pickerView selection bar by resetting the property showsSelectionIndicator of UIImagePicker and adding a overlay view. But the problem is, the overlay view should be transparent so that the wheel behind it is visible. But the other application somehow does it even though the selection bar is not transparent. Any ideas on how to achieve this feat? Thanks and Regards, Raj

    Read the article

  • UIPickerView with NSDictionary

    - by Dave
    I am a .NET programmer and new to Objective C. I am trying to make a UIPickerView which acts like a .NET dropdownlist. User sees the list of text and selects one and the selected value (which is the ID) is used in code. I have been browsing for almost half a day trying to figure this out. I could add a regular PickerView with list of strings, picker view with mulitple components and picker view with dependent components none of which seems to answer my query. Please help.

    Read the article

  • Using a UIPickerView to make a CoreData Relationship

    - by DVG
    Okay, so I have a fairly simple application set up. I have two different CoreData Entities, Games and Platforms, each have one attribute: name, and they have a one-to-many relationship between them. Platforms are populated on the first launch of the application, and will never change as a result of user input. I'm working on my Add view to let the user add new games to their personal database, and each game should select from a platform. The add view itself is a grouped table view with static custom cells. Tapping the platform cell should advance the user to another view to select the platform. My thought is that UIPickerView seems like a logical choice for the control, since the Platform list is static, but I'm not sure how to use it with CoreData. Even if I construct a fetch request to get the Platform objects and extract the strings out, how do I go about linking the new Game object to the original Platform object?

    Read the article

  • Adding a UIPickerView over a UITabBarController

    - by Kai
    I'm trying to have a UIPickerView slide from the bottom of the screen (over the top of a tab bar) but can't seem to get it to show up. The actual code for the animation is coming from one of Apple's example code projects (DateCell). I'm calling this code from the first view controller (FirstViewController.m) under the tab bar controller. - (IBAction)showModePicker:(id)sender { if (self.modePicker.superview == nil) { [self.view.window addSubview:self.modePicker]; // size up the picker view to our screen and compute the start/end frame origin for our slide up animation // // compute the start frame CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; CGSize pickerSize = [self.modePicker sizeThatFits:CGSizeZero]; CGRect startRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height, pickerSize.width, pickerSize.height); self.modePicker.frame = startRect; // compute the end frame CGRect pickerRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height - pickerSize.height, pickerSize.width, pickerSize.height); // start the slide up animation [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; // we need to perform some post operations after the animation is complete [UIView setAnimationDelegate:self]; self.modePicker.frame = pickerRect; // shrink the vertical size to make room for the picker CGRect newFrame = self.view.frame; newFrame.size.height -= self.modePicker.frame.size.height; self.view.frame = newFrame; [UIView commitAnimations]; // add the "Done" button to the nav bar self.navigationItem.rightBarButtonItem = self.doneButton; }} Whenever this action fires via a UIBarButtonItem that lives in a UINavigationBar (which is all under the FirstViewController) nothing happens. Can anyone please offer some advice?

    Read the article

  • iPad and UIPickerView (or UIDatePickerView)

    - by Staros
    Hey all, Has anyone had any luck using a UIPicker in the 3.2 SDK? I'm in the middle of porting an iPhone application over to an iPad and that's the one thing I can't seem to get to work. I've tried... -Creating an action sheet, add the picker as a subview and displaying it. -Creating that above action sheet, making it the view of a generic ViewController, adding that VC to a UIPopover -Making just the picker the view of a generic ViewController, adding that VC to a UIPopover With the action sheet it doesn't even attempt to draw it. In the popover view it attempts to draw but doesn't get rendered correctly. Just wanted to check to see if anyone has accomplished this and if so how. Thanks everyone!

    Read the article

  • Multiple row selection in uipickerView

    - by medma
    Hi frends, I have implemented multiple row selection by making uipicker with components and rows = 0, and add uitableview as subview to picker. But now i have a problem that some of the values in the table are checked automatically which creates problem in my application. plz tell me what to do to rectify this. Thanx.

    Read the article

  • How to have two UIPickerViews together in one ViewController?

    - by 0SX
    I'm trying to put 2 UIPickerViews together in one ViewController. Each UIPickerView has different data arrays. I'm using interface builder to link the pickers up. I know I'll have to use separate delegates and dataSources but I can't seem to hook everything up with interface builder correctly. Here's all my code: pickerTesting.h #import <UIKit/UIKit.h> #import "picker2DataSource.h" @interface pickerTestingViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>{ IBOutlet UIPickerView *picker; IBOutlet UIPickerView *picker2; NSMutableArray *pickerViewArray; } @property (nonatomic, retain) IBOutlet UIPickerView *picker; @property (nonatomic, retain) IBOutlet UIPickerView *picker2; @property (nonatomic, retain) NSMutableArray *pickerViewArray; @end pickerTesting.m #import "pickerTestingViewController.h" @implementation pickerTestingViewController @synthesize picker, picker2, pickerViewArray; - (void)viewDidLoad { [super viewDidLoad]; pickerViewArray = [[NSMutableArray alloc] init]; [pickerViewArray addObject:@" 100 "]; [pickerViewArray addObject:@" 200 "]; [pickerViewArray addObject:@" 400 "]; [pickerViewArray addObject:@" 600 "]; [pickerViewArray addObject:@" 1000 "]; [picker selectRow:1 inComponent:0 animated:NO]; picker2.delegate = self; picker2.dataSource = self; } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)picker; { return 1; } - (void)pickerView:(UIPickerView *)picker didSelectRow:(NSInteger)row inComponent:(NSInteger)component { } - (NSInteger)pickerView:(UIPickerView *)picker numberOfRowsInComponent:(NSInteger)component; { return [pickerViewArray count]; } - (NSString *)pickerView:(UIPickerView *)picker titleForRow:(NSInteger)row forComponent:(NSInteger)component; { return [pickerViewArray objectAtIndex:row]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end And I have a separate class for the other datasource. picker2DataSource.h @interface picker2DataSource : NSObject <UIPickerViewDataSource, UIPickerViewDelegate> { NSMutableArray *customPickerArray; } @property (nonatomic, retain) NSMutableArray *customPickerArray; @end picker2DataSource.m #import "picker2DataSource.h" @implementation picker2DataSource @synthesize customPickerArray; - (id)init { // use predetermined frame size self = [super init]; if (self) { customPickerArray = [[NSMutableArray alloc] init]; [customPickerArray addObject:@" a "]; [customPickerArray addObject:@" b "]; [customPickerArray addObject:@" c "]; [customPickerArray addObject:@" d "]; [customPickerArray addObject:@" e "]; } return self; } - (void)dealloc { [customPickerArray release]; [super dealloc]; } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)picker2; { return 1; } - (void)pickerView:(UIPickerView *)picker2 didSelectRow:(NSInteger)row inComponent:(NSInteger)component { } - (NSInteger)pickerView:(UIPickerView *)picker2 numberOfRowsInComponent:(NSInteger)component; { return [customPickerArray count]; } - (NSString *)pickerView:(UIPickerView *)picker2 titleForRow:(NSInteger)row forComponent:(NSInteger)component; { return [customPickerArray objectAtIndex:row]; } @end Any help or code examples would be great. Thanks.

    Read the article

  • How can I make a UIPickerView like a UIDatePicker?

    - by iamthepiguy
    I have a custom UIViewController subclass which acts as Datasource and Delegate for a UIPickerView which I would like to serve two different purposes, as each are simple enough, and don't really warrant separate files. One operation must be as a custom picker, and this works fine. However, for the other operation, I want it to act just like a UIDatePicker. The problem is, UIDatePicker is a subclass of UIControl, not UIPickerView. Is there any sort of enum value I can set in a method (or other way) that will set the UIPickerView to act as a date picker? Or do I have to make two completely different classes and use them differently (pain in the ass)?

    Read the article

1 2 3 4  | Next Page >