【发布时间】:2016-04-19 15:07:32
【问题描述】:
在我的应用程序中有一个 UITable。在表格单元格中,我添加了 UIStackView 以在加载表格单元格时填充。
在向下滚动表格之前工作正常,当我向上和向下滚动时,堆栈视图会添加更多元素。 (elements表示UIButtons,以后我会用UIlabel代替)
我没有任何想法来解决这个问题。谢谢。。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
UIStackView *stkItems=(UIStackView *)[cell viewWithTag:8];
for(int i=0;i<5;i++) {
UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
[btn setTitle:@"test btn" forState:UIControlStateNormal];
[stkItems addArrangedSubview:btn];
}
}
【问题讨论】:
标签: ios objective-c uitableview uistackview