Guten Tag,Bild angezapft von UIPickerView
Ich habe ein UIPickerView, die in UIPickerView ausgewählte Bilder von Vögeln, anderes Bild mit verschiedenen Reihe zeigt, jetzt habe ich das Bild für weitere Informationen über den Vogel erschließen wollen, also bin ich Ich denke über ein TextView nach, das erscheint, wenn das Bild angetippt wird. Wie würde ich das in meinem Code implementieren? Ich bin neu im Programmieren und jede Hilfe wird sehr geschätzt. Das ist bisher mein Code.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//Load up NSArray object
_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",@"Toppskarfur",@"Helsingi",@"Stokkönd", @"Urtönd",@"Rauðhöfðaönd",@"Duggönd",@"Skúfönd",@"Hávella",@"Toppönd",@"Hvítmáfur",@"Hettumáfur",@"Rita",@"Frá 15.apríl til 14.júlí",@"Kjói(í og við friðlýst æðarvarp)",@"Frá 1.september til 25.apríl",@"Álka",@"Langvía",@"Stuttnefja",@"Teista",@"Lundi",@"-Breytilegt-",@"Rjúpa", 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];
}
- (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.font = [UIFont fontWithName:@"Helvetica" size:22];
if (row == 0 || row == 5 || row == 8 || row == 23 || row == 25 || row == 31) {
label.textColor = [UIColor redColor];
}else{
label.textColor = [UIColor blackColor];
}
label.text = [_fuglar objectAtIndex:row];
return label;
if (row == 0) {
[UIImage imageNamed:@"byssa2"];
} else {
[_fuglar objectAtIndex:row];
}
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
//Create UIImage objects
UIImage * byssa2Image = [UIImage imageNamed:@"byssa2.jpg"];
UIImage * hrafnImage = [UIImage imageNamed:@"hrafn.jpg"];
UIImage * svartbakurImage = [UIImage imageNamed:@"Svartbakur.jpg"];
UIImage * silfurmafurImage = [UIImage imageNamed:@"Silfurmafur.jpg"];
UIImage * silamafurImage = [UIImage imageNamed:@"Silamafur.jpg"];
UIImage * gragaesImage = [UIImage imageNamed:@"Gragaes.jpg"];
UIImage * heidargaesImage = [UIImage imageNamed:@"Heidagaes.jpg"];
UIImage * fyllImage = [UIImage imageNamed:@"fyll.jpg"];
UIImage * toppskarfurImage = [UIImage imageNamed:@"Dilaskarfur1.jpg"];
UIImage * dilaskarfurImage = [UIImage imageNamed:@"Toppskarfur.jpg"];
UIImage * helsingiImage = [UIImage imageNamed:@"Helsingi.jpg"];
UIImage * stokkondImage = [UIImage imageNamed:@"Stokkond.jpg"];
UIImage * urtondImage = [UIImage imageNamed:@"Urtond.jpg"];
UIImage * raudhofdaondImage = [UIImage imageNamed:@"Raudhofdaond.jpg"];
UIImage * duggondImage = [UIImage imageNamed:@"Duggond.jpg"];
UIImage * skufondImage = [UIImage imageNamed:@"Skufond.jpg"];
UIImage * havellaImage = [UIImage imageNamed:@"Havella.jpg"];
UIImage * toppondImage = [UIImage imageNamed:@"Toppond.jpg"];
UIImage * hvitmafurImage = [UIImage imageNamed:@"Hvitmafur.jpg"];
UIImage * hettumafurImage = [UIImage imageNamed:@"Hettumafur.jpg"];
UIImage * ritaImage = [UIImage imageNamed:@"Rita.jpg"];
UIImage * alkaImage = [UIImage imageNamed:@"Alka.jpg"];
UIImage * langviaImage = [UIImage imageNamed:@"Langvia1.jpg"];
UIImage * stuttnefjaImage = [UIImage imageNamed:@"Stuttnefja.jpg"];
UIImage * teistaImage = [UIImage imageNamed:@"Teista1.jpg"];
UIImage * lundiImage = [UIImage imageNamed:@"Lundi.jpg"];
UIImage * rjupaImage = [UIImage imageNamed:@"Rjupa1.jpg"];
UIImage * kjoiImage = [UIImage imageNamed:@"Kjoi.jpg"];
switch (row) {
break;
case 0:
fuglarImage.image = byssa2Image;
break;
case 1:
fuglarImage.image = hrafnImage;
break;
case 2:
fuglarImage.image = svartbakurImage;
break;
case 3:
fuglarImage.image = silfurmafurImage;
break;
case 4:
fuglarImage.image = silamafurImage;
break;
case 6:
fuglarImage.image = gragaesImage;
break;
case 7:
fuglarImage.image = heidargaesImage;
break;
case 9:
fuglarImage.image = fyllImage;
break;
case 10:
fuglarImage.image = toppskarfurImage;
break;
case 11:
fuglarImage.image = dilaskarfurImage;
break;
case 12:
fuglarImage.image = helsingiImage;
break;
case 13:
fuglarImage.image = stokkondImage;
break;
case 14:
fuglarImage.image = urtondImage;
break;
case 15:
fuglarImage.image = raudhofdaondImage;
break;
case 16:
fuglarImage.image = duggondImage;
break;
case 17:
fuglarImage.image = skufondImage;
break;
case 18:
fuglarImage.image = havellaImage;
break;
case 19:
fuglarImage.image = toppondImage;
break;
case 20:
fuglarImage.image = hvitmafurImage;
break;
case 21:
fuglarImage.image = hettumafurImage;
break;
case 22:
fuglarImage.image = ritaImage;
break;
case 24:
fuglarImage.image = kjoiImage;
break;
case 26:
fuglarImage.image = alkaImage;
break;
case 27:
fuglarImage.image = langviaImage;
break;
case 28:
fuglarImage.image = stuttnefjaImage;
break;
case 29:
fuglarImage.image = teistaImage;
break;
case 30:
fuglarImage.image = lundiImage;
break;
case 32:
fuglarImage.image = rjupaImage;
break;
default:
break;
}
}
hinzufügen, auf dieser Aktion Methode Öffnen Sie die Ansicht für detaillierte Beschreibung –
Erarbeiten Sie mehr über Ihre Anforderung. Das Anzeigen von Bildern in Picker View ist nicht so gut. Sie können es in der Sammlungsansicht anzeigen. –
@BalajiRamakrishnan - Du hast die Frage zu didSelectRow gesehen. Basierend auf der Auswahl zeigt er das einzelne Bild auf imageview –