Sunday, December 1, 2013

About UIPickerView, some of the questions bothering me seven hours yesterday, the tragedy

Environment: Xcode4.2 + ios5.0
Run has prompted Thread 1: Program received signal: "SIGABRT"

h file as follows
 @ interface ViewController: UIViewController  {
UIPickerView * uipickerview;
NSArray * column1;
}
@ Property (strong, nonatomic) IBOutlet UIPickerView * uipickerview;
@ Property (strong, nonatomic) IBOutlet NSArray * column1;
@ End


ViewController.m code below
have a question: @ implementation ViewController behind the phrase has yellow tips "Incomplete implementation", if not removed H file tips, and wondered, I see online video, did not like this. m file has been written on the last paragraph of the three implementations Yeah ... feel like we can not say the same recognition
- (NSInteger) numberOfComponentsInpickerView: (UIPickerView *) pickerView
- (NSInteger) pickerView: (UIPickerView *) pickerView numberOfRowsInComponent: (NSInteger) component
- (NSString *) pickerView: (UIPickerView *) pickerView titleForRow: (NSInteger) row forComponent: (NSInteger) component

Figure:

 @ 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

The result has been the emergence of this error

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)


----------------------------------------------
Alas, saw an afternoon did not see where the wrong ... especially to help


Reply:
@ Property (strong, nonatomic) IBOutlet NSArray * column1;
iboutlet removed, [column1 count]; into
[Self.column1 count]; Try

Reply:
numberOfComponentsInpickerView

To


numberOfComponentsInPickerView

Sensitive. . .
Reply:
Sensitive issues now, according to the upstairs first changed to say.
Reply:
A closer look also really sensitive issue. . . . This entrust you to define which directly copied ah, do not know where you copied the.
Reply:
Ah, but yes yes Picker written picer it. . I have been wondering, is automatically generated xcode, ah, how will become lowercase, and today they tried, automatic generation really is uppercase. .
My mistake, sloppy


Thank you, friends, 2nd Floor

No comments:

Post a Comment