当前位置: 代码迷 >> Iphone >> 关于UIPickerView,一些疑问,困扰了小弟我昨天7个小时了,悲剧
  详细解决方案

关于UIPickerView,一些疑问,困扰了小弟我昨天7个小时了,悲剧

热度:60   发布时间:2016-04-25 06:32:00.0
关于UIPickerView,一些疑问,困扰了我昨天7个小时了,悲剧
环境是:Xcode4.2+ ios5.0
运行一直提示Thread 1:Program received signal:"SIGABRT"

h文件如下
C/C++ code
@interface ViewController : UIViewController<UIPickerViewDataSource,UIPickerViewDelegate>{    UIPickerView *uipickerview;    NSArray *column1;}@property (strong, nonatomic) IBOutlet UIPickerView *uipickerview;@property (strong, nonatomic) IBOutlet NSArray *column1;@end


ViewController.m代码如下
有个问题:@implementation ViewController这句后面一直黄色提示“Incomplete implementation”,如果把H文件中<UIPickerViewDataSource,UIPickerViewDelegate>去掉就不提示了,很纳闷,我看网上的视频,也没这样。m文件末段已经写上了那三个实现方法了呀...感觉像不能说识别一样
-(NSInteger)numberOfComponentsInpickerView:(UIPickerView *)pickerView
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
如图:

C/C++ code
@implementation ViewController@synthesize uipickerview;@synthesize column1;....- (void)viewDidLoad{    [super viewDidLoad];    NSArray *array = [[NSArray alloc] initWithObjects:@"Horse", @"Sheep", @"Pig", @"Dog", @"Cat", @"Chicken", @"Duck", @"Goose", nil];     self.column1 = array;}....#pragma mark -#pragma mark Picker Data Source Methods-(NSInteger)numberOfComponentsInpickerView:(UIPickerView *)pickerView{    return 1;}-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {    return [column1 count];}#pragma mark Picker Delegate Methods-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{    return [column1 objectAtIndex:row];    }@end

运行结果一直出现这个错误

2012-07-07 21:01:30.832 GameTest[5101:ef03] -[ViewController numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0x65ae530
2012-07-07 21:01:30.833 GameTest[5101:ef03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0x65ae530'
*** First throw call stack:
(0x114a272 0x12d9ce6 0x114bf0d 0x114c2a3 0x10b0ff8 0x10b0c12 0xa92d 0xb440 0x50209 0x114c092 0x1b18bf5 0x1b22aef 0x1aa9401 0x1aab300 0x1b365d4 0x1079e 0x10e5d 0x1f8d4 0x20380 0x13d00 0xde67fe 0x111e435 0x1082d72 0x108165a 0x1080b04 0x1080a1b 0x1057f 0x11cf2 0x2358 0x22b5)
terminate called throwing an exception(gdb) 


——————————————————————————————————————————————
唉,看了一下午也没看出哪儿错了...特来求救



------解决方案--------------------
numberOfComponentsInpickerView

改为


numberOfComponentsInPickerView

大小写。。。