1
我做了UIPickerView并添加到viewcontroller'view。UIPickerView的组件宽度是否可以手动调整?
我手动调整了pickerview的宽度。
当你看图片,组件的内容之间不匹配的宽度以及组件的宽度和
pickerview的宽度和组件的宽度。
有没有像UILabel的sizeToFit方法?
expected code is :
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
switch(component) {
[pickerView.label sizeToFit];
}
}
================= Following is mycode ====================================================
- (void)viewDidLoad {
self.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
[super viewDidLoad];
UIPickerView *pickerView = [[[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)] autorelease];
pickerView.dataSource = self;
pickerView.delegate = self;
pickerView.showsSelectionIndicator = YES;
[self.view addSubview:pickerView];
activities = [[NSArray alloc] initWithObjects:@"sleeping", @"eating", @"working", @"studying", @"walking", @"thinking", @"considering", @"testing", @"talking", nil];
feelings = [[NSArray alloc] initWithObjects:@"awesome", @"sad", @"happy", nil];
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
switch(component) {
case 0: return 100;
case 1: return 200;
}
}
会给一些代码? –
组件和组件的内容大小是否适当调整? –
您是否尝试过我在上面...?,评论整个方法widthForComponent&运行项目 –