0
我创建了一个应用程序,我使用“for循环”创建视图列表,并且每个视图都包含一些标签和pickerViews。当我点击并从pickerView中选择任何值时,我的uilabel会更新,但当我点击任何其他pickerview并从中选择不同的值时,它会更新到以前的每个标签。所以通过这种方式,每个UILabel中只显示最后一个选择器值。通过从选取器填充UIlabel上的数据查看
我知道它发生的原因,因为我创建了UILabel作为属性并通过“self”访问。但是,如果我不以这种方式访问,那么如何更新该标签的值。
示例代码:
for (NSMutableDictionary *itemDict in self.returnItemsArray) {
self.issueLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(18, shipmentY+3, 270, 20)];
[_issueLabel setNumberOfLines:0];
[_issueLabel setTextColor:LR_darkgray_color];
[_issueLabel setFont:[UIFont systemFontOfSize:15]];
[_issueLabel setTextAlignment:NSTextAlignmentLeft];
[_issueLabel setTag:index];
[_issueLabel setText:@"Size Change"];
[returnOrderInfoView addSubview:_issueLabel];
}
-(void)picker:(LRPickerView *)picker closedWithSelectedIndex:(NSInteger)index{
if (picker.type == SIZE_PICKER){
[self.issueLabel setText:[[_sizeDictionary objectForKey:selectedVar]uppercaseString]];
}
}
让我知道你需要的任何其他信息。
你说:“当我点击并选择任意值从的UILabel获取并更新:
然后在
picker:closedWithSelectedIndex:
,该标签可以从阵列中使用类似检索更新,但当我点击任何其他pickerview并从中选择不同的值时,它会更新到每个以前的标签。“这绝对没有任何意义。我甚至会称之为“[**词沙拉**](https://en.wikipedia.org/wiki/Word_salad)”。 –