我正在使用UIPickerview。我想把我的观点视为:
但我得到了:
有没有办法让selectionIndicator靠近字符串?并隐藏将在selectionIndicator上方的数字?
答案 0 :(得分:0)
lakhan bhojwan尝试下面的答案。我创建了一个样本。它完美无缺。
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UIPickerViewDelegate,UIPickerViewDataSource>
@property (strong, nonatomic) IBOutlet UIPickerView *pickerCustom;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
{
NSMutableArray *arrPicker;
}
@end
@implementation ViewController
@synthesize pickerCustom;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
arrPicker = [[NSMutableArray alloc]initWithObjects:@"Rate this page",@"10",@"9",@"8",@"7",@"6",@"5",@"4",@"3",@"2",@"1",nil];
[pickerCustom selectRow:1 inComponent:0 animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// The number of columns of data
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
// The number of rows of data
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [arrPicker count];
}
// The data to return for the row and component (column) that's being passed in
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return arrPicker[row];
}
@end
以下输出截图