嗨,我有一个选择器视图。来自Web服务的这个选择器视图来了 加载数据中。这个选择器视图是2部分。选择器视图1.部分是 项目名。和Picker视图2.部分是项目编号。我想要 写在我的标签上相同的选择器视图是1.我想在标签上写的部分 “A1 Unitesi”,我想写在label2“002”,但我的标签上 写“DevamEdenProjelerObje:”0xada6fe0“>为什么在我的标签上写 “DevamEdenProjelerObje:”0xada6fe0“>?`你能帮我吗?我怎么能 在我的标签上写着“A1 Unitesi”?
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (component == 0) {
return [RaporlarList count];
}
return [RaporlarList count];
}
#pragma mark Picker Delegate Methods
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (component == 0) {
eObje = [RaporlarList objectAtIndex:row];
return eObje.ProjeAdii;
}
eObje = [RaporlarList objectAtIndex:row];
return eObje.ProjeNoo;
}
#pragma mark -
#pragma mark PickerView Delegate
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (component == 0)
{
NSString *resultString = [[NSString alloc] initWithFormat:@"Proje Adı : %@", [RaporlarList objectAtIndex:row]];
lblProjeAdi.text = [NSString stringWithFormat:@"%@", resultString];
}
else
{
NSString *resultString = [[NSString alloc] initWithFormat:@"Proje No: %@", [RaporlarList objectAtIndex:row]];
lblProjeNo.text = resultString;
}
}
答案 0 :(得分:2)
我不知道我是否理解得好但是不是更好吗?
if (component == 0)
{
NSString *resultString = [[NSString alloc] initWithFormat:@"Proje Adı : %@", [[RaporlarList objectAtIndex:row] ProjeAdii]];
lblProjeAdi.text = [NSString stringWithFormat:@"%@", resultString];
}
else
{
NSString *resultString = [[NSString alloc] initWithFormat:@"Proje No: %@", [[RaporlarList objectAtIndex:row] ProjeNoo]];
lblProjeNo.text = resultString;
}