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

标签 ios objective-c uitableview ios7

我使用以下教程创建了一个可扩展的表格 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/

相关文章:

objective-c - 我如何知道哪个事件导致了对 IBAction 的调用?

objective-c - 如何从 NSArray 获取特定长度的字符串?

ios - 键值编码失败

ios - IOS 上的 NSTimer 和电池充电

objective-c - 处理大量物体

objective-c - UITableView 动画期间的用户交互

iphone - 手势在 UITableViewCell 的右侧不起作用

objective-c - UITableView 中的单元格到新 View Objective-C

ios - 在 iOS 上使用 quartz 渲染某些 pdf 文件时出现字体错误

ios - 随机图像到(许多) ImageView