我已经尝试将选择器的委托设置为self,但这也不起作用.提前致谢.
这是我的.h文件:
@interface BACcalcVIEwController : UIVIEwController<UIPickerVIEwDataSource,UIPickerVIEwDelegate>@property(strong,nonatomic) IBOutlet UIPickerVIEw *personInfoPicker;@property(strong,nonatomic) NSArray *heightsArray;@property(strong,nonatomic) NSArray *weightsArray;@property(strong,nonatomic) NSArray *timeArray;@end
这是我的.m文件:
@interface BACcalcVIEwController () <UIPickerVIEwDataSource,UIPickerVIEwDelegate>@end@implementation BACcalcVIEwController@synthesize personInfoPicker,heightsArray,weightsArray,timeArray;- (voID)vIEwDIDLoad{[super vIEwDIDLoad];heightsArray = [NSArray arrayWithObjects: @"5ft 0in",@"5ft 1in",@"5ft 2in",@"5ft 3in",@"5ft 4in",@"5ft 5in",@"5ft 6in",@"5ft 7in",@"5ft 8in",@"5ft 9in",@"5ft 10in",@"5ft 11in",@"6ft 1in",@"6ft 2in",@"6ft 3in",@"6ft 4in",@"6ft 5in",@"6ft 6in",@"6ft 7in",@"6ft 8in",nil];weightsArray = [NSArray arrayWithObjects: @"100",@"110",@"120",@"130",@"140",@"150",@"160",@"170",@"180",@"190",@"200",@"210",@"220",@"230",@"240",@"250",@"260",nil];timeArray = [NSArray arrayWithObjects: @"1",@"2",@"3",@"4",@"5",@"6",nil];}- (NSInteger)numberOfComponentsInPickerVIEw:(UIPickerVIEw *)personInfoPicker{ return 3;}- (NSInteger)pickerVIEw:(UIPickerVIEw *)personInfoPicker numberOfRowsInComponent: (NSInteger)component{ if (component == 0) return [heightsArray count]; else if (component == 1) return [weightsArray count]; else return [timeArray count];}- (Nsstring *)pickervIEw:(UIPickerVIEw *)personInfoPicker TitleForRow:(NSInteger)row forComponent:(NSInteger)component{ if (component == 0) return [heightsArray objectAtIndex:row]; else if (component == 1) return [weightsArray objectAtIndex:row]; else return [timeArray objectAtIndex:row];}@end解决方法 您需要设置选择器视图的dataSource并在填充数组后调用reloadAllComponents.
self.personInfoPicker.delegate = self;self.personInfoPicker.dataSource = self;[self.personInfoPicker reloadAllComponents];总结
以上是内存溢出为你收集整理的iphone – UIPickerView不显示数据全部内容,希望文章能够帮你解决iphone – UIPickerView不显示数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)