仍在尝试找出 UI 选择器视图,现在已经有 2 天了,出于某种原因,我只是坚持这一点。请就我做错了什么提供任何建议。我有一个黄色三角形表示“不完整的实现”和一个红色三角形表示“使用未声明的标识符 numberOfComponentsinPickerView”
。H
#import <UIKit/UIKit.h>
@interface pick3 : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate> {
UIPickerView *select;
NSArray *list;
}
@property (strong, nonatomic) IBOutlet UIPickerView *select;
@end
.m
#import "pick3.h"
@interface pick3 ()
@end
@implementation pick3
@synthesize select;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
{
list = [[NSArray alloc] initWithObjects:@"Employed", @"Student", @"Retired", @"Homemaker", @"Self-employed", @"Unemployed", @"Other", nil];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
//One column
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
//set number of rows
return list.count;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
//set item per row
return [list objectAtIndex:row];
}
}