我使用以下教程创建了一个可扩展的表格 View : Expandable-Collapsable-TableView
我的形象:
我想从左侧开始缩小每一行之间的间距。距离太大。 任何人都可以帮助我定位行。
最佳答案
- (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/