UiPickerView with Images Error - iphone

I have UiPickerView and colorCode.Plist - which contains names of images.
I need to add these images to my picker View.
UipickerView
4 component
10 images in first 3 component
4 images in 4th component
Programs like Resistor Colour Code for Electrical use. (Error thrown)
{
#interface ResistorsColorView ()
{
NSArray *colorCode;
}
#end
#implementation ResistorsColorView
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"colorCode" ofType:#"plist"];
colorCode = [[NSArray alloc] initWithContentsOfFile:filePath];
}
# pragma mark - Datasource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return colorCode.count;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [colorCode[component]count];
}
//- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent: (NSInteger)component{
//
// return colorCode[component][row];
//}
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent: (NSInteger)component reusingView:(UIView *)view{
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
imageView.image = colorCode[component][row];
imageView.image = [UIImage imageNamed:[record objectForKey:#"row1"]];
[v addSubview:imageView];
return v;
}
#end

reason: '-[__NSCFString _isResizable]: unrecognized selector sent to instance 0x6e6e300' –

Related

How to set the text alignment in picker view iOS

I need to set the alignment of the text in picker view but my solutions doesn't work.
This is my code so far. I used array to store values on the picker view.
- (void)viewDidLoad{
[super viewDidLoad];
self.source = [[NSMutableArray alloc]
initWithObjects:#" 5 Minutes", #"10 Minutes", #"15 Minutes", #"20 Minutes",#"25 Minutes",#"30 Minutes",#"35 Minutes",#"40 Minutes",#"45 Minutes",#"50 Minutes",#"55 Minutes",#"60 Minutes", nil];
self.picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 275.0, 320.0, 120.0)];
self.picker.delegate = self;
self.picker.dataSource = self;
[self.view addSubview:self.picker];
[self.picker selectRow:2 inComponent:0 animated:YES];}
then,
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [source objectAtIndex:row];
}
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return [source count];
}
However, it works fine when it displays the values. But when I align the text at the center, instead of displaying the text(values on picker view), the picker view becomes empty. This is the code on how I've done the alignment at the center.
- (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 = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
return label;
}
What might be the solution for this?
Please help me regarding this problem.
Thanks.
i done with this code for UIlabel text show in center of tableView like:-
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)];
if (component == 0) {
label.font=[UIFont boldSystemFontOfSize:22];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.text = [NSString stringWithFormat:#"%#", [source objectAtIndex:row]];
label.font=[UIFont boldSystemFontOfSize:22];
}
[label autorelease];
return label;
}
Code output is
For swift 3 we can use
label.textAlignment = NSTextAlignment.center
use this code instead of your code..
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UIView *viewTemp = [[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 44)]autorelease];
[viewTemp setBackgroundColor:[UIColor clearColor]];
UILabel *lbl = [[[UILabel alloc]initWithFrame:CGRectMake(5, 0, 300, 37)]autorelease];
[lbl setBackgroundColor:[UIColor clearColor]];
[lbl setFont:[UIFont boldSystemFontOfSize:22]];
lbl.text = #"Some Text";
[lbl setTextAlignment:UITextAlignmentCenter];
[viewTemp addSubview:lbl];
return viewTemp;
}
Here i return one UIView in which i add UILable see above code so your whole view display with UILable properly and also set backGroundColor of UIView is clear so its display layout of UIPickerView.
I also display star like text in this UIPickerView.
See images Bellow..
Try this:
label.textAlignment = NSTextAlignmentCenter;

Get value from detailTextLabel after PickerInputViewCell

I have a Custom cell that shows a pickerView when you select a row.
Then you change the value and put it on detailTextLabel.
But this method get the value before it changes.
//Custom Cell
SimplePickerInputTableViewCell *cell = (SimplePickerInputTableViewCell *) [_tableView dequeueReusableCellWithIdentifier:cellIndentifier2];
if (!cell) {
cell = [[SimplePickerInputTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIndentifier2];
UIImageView *lineView2 = [[UIImageView alloc] initWithFrame:CGRectMake(-2, 45, 320, 10)];
lineView2.image = [UIImage imageNamed:#"linha_horizontal.png"];
[cell addSubview:lineView2];
_opcaoTitle = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 200, 20)];
_opcaoTitle.textAlignment = UITextAlignmentLeft;
_opcaoTitle.textColor = [UIColor blackColor];
_opcaoTitle.text = #"Pista - Feminino";
[cell addSubview:_opcaoTitle];
_opcaoValueF = [[UILabel alloc] initWithFrame:CGRectMake(180, 15, 100, 20)];
_opcaoValueF.textColor = [UIColor blackColor];
[cell addSubview:_opcaoValueF];
}
_opcaoValueF.text = [NSString stringWithFormat:#"R$ %#,00", _eventFemininoValue];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
[cell setValue:#"0"];
return cell;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[_tableView deselectRowAtIndexPath:indexPath animated:YES];
NSString *s = [[[tableView cellForRowAtIndexPath:indexPath] detailTextLabel] text];
NSLog(#"String is: %#", s);
int i = [s intValue];
NSLog(#"This is the int value: %d", i);
}
SimplePicker.m
#import "SimplePickerInputTableViewCell.h"
#implementation SimplePickerInputTableViewCell
#synthesize delegate;
#synthesize value;
__strong NSArray *values = nil;
+ (void)initialize {
values = [NSArray arrayWithObjects:#"0", #"1", #"2", #"3", #"4", #"5", #"6", #"7", #"8", #"9", #"10", nil];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.picker.delegate = self;
self.picker.dataSource = self;
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Initialization code
self.picker.delegate = self;
self.picker.dataSource = self;
}
return self;
}
- (void)setValue:(NSString *)v {
value = v;
self.detailTextLabel.text = value;
self.detailTextLabel.textColor = [UIColor whiteColor];
self.detailTextLabel.backgroundColor = [UIColor clearColor];
if (![value isEqualToString:#"0"]) {
[self.picker selectRow:[values indexOfObject:value] inComponent:0 animated:YES];
}
_backgroundValue = [[UIImageView alloc] initWithFrame:CGRectMake(285, 3, 40, 40)];
_backgroundValue.image = [UIImage imageNamed:#"home_icon_popular.png"];
[self addSubview:_backgroundValue];
[self sendSubviewToBack:_backgroundValue];
}
#pragma mark -
#pragma mark UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return [values count];
}
#pragma mark -
#pragma mark UIPickerViewDelegate
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [values objectAtIndex:row];
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
return 44.0f;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
return 300.0f; //pickerView.bounds.size.width - 20.0f;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
self.value = [values objectAtIndex:row];
if (delegate && [delegate respondsToSelector:#selector(tableViewCell:didEndEditingWithValue:)]) {
[delegate tableViewCell:self didEndEditingWithValue:self.value];
}
}
The problem is that you are getting the value as soon as the new cell is created (the cell is probably not even drawn on the screen at this time). To solve this you should capture the value when the use dismisses the picker view.
From the additional code you provided
1) Set up a delegate for the table view cell:
cell.delegate = self;
You can do this right after you create it
2) Add an implementation of tableViewCell:didEndEditingWithValue:
- (void)tableViewCell:(UITableViewCell*)cell didEndEditingWithValue:(NSValue*)value
{
NSLog(#"Value is %#", value);
}

How to use UIPickerView on second ViewController

" I am creating a application for IPhone in which I have to creat a login page. after getting the response from the server..it will navigate the user to next view. in next view, i m using a UIPickerView. but it is not working.. becoz i only know that how to use it in individual app . but i dont knw how to use it in second ViewController of the application??"
You can getPicker using this
-(void)getValuePicker
{
ViewForValuePicker = [[UIView alloc]initWithFrame:CGRectMake(0, 219, 320, 266)];
UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
toolBar.barStyle = UIBarStyleBlackOpaque;
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(doneBtnPressToGetValue)];
[toolBar setItems:[NSArray arrayWithObject:btn]];
[ViewForValuePicker addSubview:toolBar];
valuePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 44, 320, 216)];
valuePicker.delegate=self;
valuePicker.dataSource=self;
valuePicker.showsSelectionIndicator=YES;
[ViewForValuePicker addSubview:valuePicker];
[appDelegate.window addSubview:ViewForValuePicker];
}
And its Delegete Method
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [pickerValueAry count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
NSMutableArray *ary = [[NSMutableArray alloc] initWithArray:pickerValueAry];
id str=[ary objectAtIndex:row];
return str;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(#"selectedRowInPicker >> %d",row);
}
in .h file this method
UIViewController<UIPickerViewDataSource,UIPickerViewDelegate>
{
IBOutlet UIPickerView *picker;
NSMutableArray *pickerArrayType;
}
//in .m file
- (void)viewDidLoad
{
[super viewDidLoad];
pickerArrayType = [[NSMutableArray alloc] initWithObjects:#"Type 1",#"Type 2",#"Type 3",#"Type 4",#"Type 5", nil]
}
# pragma mark - picker Methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView1 didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
lbl.text = [pickerArrayType objectAtIndex:row];
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [pickerArrayType count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [pickerArrayType objectAtIndex:row];
}

Delegate methods of UITableView are not responding

I am quite new to IOS development, so forgive me if this problem turns out to be trivial. The following is the case:
I want to be able to call the didSelectRowAtIndexPath method to trigger some action when a user interacts with a table view cell. However, it seems that this method is never called for some reason. I am fairly certain that my code is valid. I set the delegate and dataSource properties and I conform to the UITableViewDelegate and UITableViewDataSource protocols.
If someone could shed some light on this, I would be very grateful.
My code:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#class Employee;
#define kTelephoneRowIndex 0
#define kEmailRowIndex 1
#define kLeftLabelTag 4096
#define kRightLabelTag 4097
#interface PersonnelDetailsViewController : UIViewController <UITableViewDelegate,
UITableViewDataSource, MFMailComposeViewControllerDelegate> {
UITableView *contactDetailsTable;
Employee *employee;
}
#property (nonatomic, retain) UITableView *contactDetailsTable;
#property (nonatomic, retain) Employee *employee;
+ (NSString *)resourceFilePath:(NSString *)fileName ofType:(NSString *)type;
#end
and my .m file
#import <QuartzCore/QuartzCore.h>
#import "PersonnelDetailsViewController.h"
#import "Employee.h"
#implementation PersonnelDetailsViewController
#synthesize contactDetailsTable, employee;
+ (NSString *)resourceFilePath:(NSString *)fileName ofType:(NSString *)type {
return [[NSBundle mainBundle] pathForResource:fileName ofType:type];
}
- (void)loadView {
[super loadView];
// Create the header view for the table view
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 110)];
// Set the image, using rounded corners
UIImage *employeeImage;
if ([employee.image length] == 0)
employeeImage = [UIImage imageNamed:#"logoL1nda70by80"];
else
employeeImage = [UIImage imageNamed:employee.image];
UIImageView *employeeImageView = [[UIImageView alloc] initWithImage:employeeImage];
employeeImageView.frame = CGRectMake(10, 15, 70, 80);
employeeImageView.layer.masksToBounds = YES;
employeeImageView.layer.cornerRadius = 5.0;
employeeImageView.layer.borderWidth = 1.0;
employeeImageView.layer.borderColor = [[UIColor grayColor] CGColor];
[headerView addSubview:employeeImageView];
UILabel *nameView = [[UILabel alloc] initWithFrame:CGRectMake(95, 35, 180, 20)];
nameView.text = employee.name;
nameView.font = [UIFont boldSystemFontOfSize:18];
[headerView addSubview:nameView];
UILabel *functionView = [[UILabel alloc] initWithFrame:CGRectMake(95, 55, 140, 16)];
functionView.text = employee.function;
functionView.textColor = [UIColor grayColor];
functionView.font = [UIFont systemFontOfSize:14];
[headerView addSubview:functionView];
[employeeImage release];
[employeeImageView release];
[nameView release];
[functionView release];
contactDetailsTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 370) style: UITableViewStyleGrouped];
contactDetailsTable.backgroundColor = [UIColor clearColor];
contactDetailsTable.tableHeaderView = headerView;
[headerView release];
contactDetailsTable.delegate = self;
contactDetailsTable.dataSource = self;
[self.view addSubview:contactDetailsTable];
}
- (void)viewDidUnload {
self.contactDetailsTable = nil;
self.employee = nil;
[super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated {
[contactDetailsTable reloadData];
}
- (void)dealloc {
[contactDetailsTable release];
[employee release];
[super dealloc];
}
#pragma mark -
#pragma mark Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;did
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *contactDetailIdentifier = #"contactDetailIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:contactDetailIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:contactDetailIdentifier] autorelease];
UILabel *leftLabel = [[UITextField alloc] initWithFrame:CGRectMake(5, 12, 70, 25)];
leftLabel.textAlignment = UITextAlignmentRight;
leftLabel.textColor = [UIColor grayColor];
leftLabel.tag = kLeftLabelTag;
leftLabel.userInteractionEnabled = NO;
[cell.contentView addSubview:leftLabel];
[leftLabel release];
UILabel *rightLabel = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 160, 25)];
rightLabel.font = [UIFont boldSystemFontOfSize:16];
rightLabel.tag = kRightLabelTag;
rightLabel.userInteractionEnabled = NO;
[cell.contentView addSubview:rightLabel];
[rightLabel release];
}
NSUInteger row = [indexPath row];
UILabel *leftLabel = (UILabel *)[cell viewWithTag:kLeftLabelTag];
UILabel *rightLabel = (UILabel *)[cell viewWithTag:kRightLabelTag];
switch (row) {
case kTelephoneRowIndex:
leftLabel.text = #"telefoon";
rightLabel.text = employee.phone;
break;
case kEmailRowIndex:
leftLabel.text = #"e-mail";
rightLabel.text = employee.email;
break;
default:
break;
}
return cell;
}
#pragma mark -
#pragma mark Table View Delegate Methods
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = indexPath.row;
if (row == 1) {
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
[mailController setToRecipients:[NSArray arrayWithObject:employee.email]];
[mailController.navigationBar setTintColor:[UIColor blackColor]];
[self presentModalViewController:mailController animated:YES];
mailController.mailComposeDelegate = self;
[mailController release];
}
NSLog(#"Row selected is: %d", row);
}
#pragma mark -
#pragma mark MFMailCompose View Delegate Methods
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self dismissModalViewControllerAnimated:YES];
}
#end
Check the doc for tableView:willSelectRowAtIndexPath::
Return an NSIndexPath object other than indexPath if you want another cell to be selected. Return nil if you don't want the row selected.
You are returning nil, basically saying the table view that you don't want that row selected. Therefore tableView:didSelectRowAtIndexPath: is not called.
When I had this problem I found the solution was to use willSelectRowAtIndexPath. In other places in the same project didSelectItemAtIndexPath is getting called fine.
#pragma mark - UITableViewDelegate
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// for some reason this is getting called instead of didSelectItemAtIndexPath
[self viewDetails:indexPath.row];
return indexPath;
}
- (void)tableView:(UITableView *)tableView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// [self viewDetails:indexPath.row];
}

Changing text size in Pickerview

How can we change the size of the text in a picker view?
Anyone please help.
You can change the font size of UIPickerView using code :
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *retval = (id)view;
if (!retval) {
retval= [[[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)] autorelease];
}
retval.font = [UIFont systemFontOfSize:22];
return retval;
}
For completeness, yakub_moriss code lacks of one line, which was in the post signaled by indragie. Without a line as
retval.text = [pickerViewArray objectAtIndex:row];
the picker will be empty.
This is also a great way to change the alignment of the text in the component too, change the textAlignment of the retval label.
Also, the background for the label should be set to clear:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *retval = (id)view;
if (!retval) {
retval = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f,
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height)];
}
retval.opaque = NO;
retval.backgroundColor = [UIColor clearColor];
retval.font = [UIFont systemFontOfSize:28];
if (component == 0) {
retval.textAlignment = UITextAlignmentRight;
retval.text = [NSString stringWithFormat:#"%d ", row];
} else {
retval.textAlignment = UITextAlignmentLeft;
retval.text = [NSString stringWithFormat:#" .%d", row];
}
return retval;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
if (component == 0) {
return 100;
}
return 88;
}
I'm using a category for this. It relies on this other category I have: http://compileyouidontevenknowyou.blogspot.com/2012/06/adding-properties-to-class-you-dont.html.
Anyway, this one looks like this:
#import <UIKit/UIKit.h>
#interface UIPickerView (CustomViewForRow)
#property (nonatomic, strong) UIFont *customViewForRowFont;
- (UIView *)customViewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;
#end
and the .m
#import "UIPickerView+CustomViewForRow.h"
#import "NSObject+AssociatedObjectSupport.h"
#implementation UIPickerView (CustomViewForRow)
static char keyForCustomViewForRowFont;
- (UIFont *)customViewForRowFont {
UIFont *retVal = [self associatedObject:&keyForCustomViewForRowFont];
if (!retVal)
retVal = [UIFont boldSystemFontOfSize:17];
return retVal;
}
- (void)setCustomViewForRowFont:(UIFont *)customViewForRowFont {
[self setAssociatedObject:customViewForRowFont forKey:&keyForCustomViewForRowFont];
}
- (UIView *)customViewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *label;
if (!view) {
view = [[UIView alloc] init];
CGRect frame = CGRectZero;
frame.size = [self rowSizeForComponent:component];
view.frame = frame;
view.backgroundColor = UIColor.clearColor;
label = [[UILabel alloc] init];
label.font = self.customViewForRowFont;
label.backgroundColor = [UIColor clearColor];
frame = view.bounds;
frame.origin.x += 7;
frame.size.width -= 14;
label.frame = frame;
[view addSubview:label];
}
label = [view.subviews objectAtIndex:0];
#try {
NSString *text = [self.delegate pickerView:self titleForRow:row forComponent:component];
if (!text)
text = #"???";
label.text = text;
} #catch (NSException *e) {
label.text = #"???";
}
return view;
}
#end
Try this
https://github.com/kafejo/CCPicker
it's very easy picker :)