gpt4 book ai didi

ios - 如何在 ios 中更改 UITableView 中一行的位置

转载 作者:行者123 更新时间:2023-11-28 19:58:35 24 4
gpt4 key购买 nike

我使用以下教程创建了一个可扩展的表格 View : Expandable-Collapsable-TableView

我的形象:

enter image description here

我想从左侧开始缩小每一行之间的间距。距离太大。任何人都可以帮助我定位行。

最佳答案

- (UITableViewCell*)createCellWithTitle:(NSString *)title image:(UIImage *)image  indexPath:(NSIndexPath*)indexPath
{
NSString *CellIdentifier = @"Cell";
ExpandableTableViewCell* cell = [self.menuTableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [UIColor grayColor];
cell.selectedBackgroundView = bgView;
cell.lblTitle.text = title;
cell.lblTitle.textColor = [UIColor blackColor];

[cell setIndentationLevel:[[[self.itemsInTable objectAtIndex:indexPath.row] valueForKey:@"level"] intValue]];

//**replace your x position**
cell.indentationWidth = 10;

float indentPoints = cell.indentationLevel * cell.indentationWidth;

cell.contentView.frame = CGRectMake(indentPoints,cell.contentView.frame.origin.y,cell.contentView.frame.size.width - indentPoints,cell.contentView.frame.size.height);

NSDictionary *d1=[self.itemsInTable objectAtIndex:indexPath.row] ;

if([d1 valueForKey:@"SubItems"])
{
cell.btnExpand.alpha = 1.0;
[cell.btnExpand addTarget:self action:@selector(showSubItems:) forControlEvents:UIControlEventTouchUpInside];
}
else
{
cell.btnExpand.alpha = 0.0;
}
return cell;
}

关于ios - 如何在 ios 中更改 UITableView 中一行的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25178253/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com