UITextField to show UIPickerView in xcode 4.3.2 using textField.inputView
Posted
by
ChromeBlue
on Stack Overflow
See other posts from Stack Overflow
or by ChromeBlue
Published on 2012-07-16T17:04:37Z
Indexed on
2012/10/05
3:38 UTC
Read the original article
Hit count: 299
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.
© Stack Overflow or respective owner