もう一度試してみましょう。アプリにピッカーがあり、このコードで問題なく動作しています
_fuglar = [[NSArray alloc]initWithObjects:@"Allt árið", @"Hrafn", @"Svartbakur",@"Silfurmáfur",@"Sílamáfur",@"Frá 20.ágúst til 15.mars",@"Grágæs",@"Heiðagæs",@"Frá 1.september til 15.mars",@"Fýll",@"Dílaskarfur", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UIPickerView Methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return _fuglar.count;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [_fuglar objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
//Create UIImage objects
UIImage * uglaImage = [UIImage imageNamed:@"ugla1.jpg"];
UIImage * ravenImage = [UIImage imageNamed:@"raven.jpg"];
UIImage * svartbakurImage = [UIImage imageNamed:@"svartbakur2.jpg"];
次に、テキストをピッカーの中央に配置して色も変更したいのですが、このコードを使用していますが、ピッカーは空白になりますが、写真やアイデアを見ることができますか?
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)];
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blueColor];
return label;