ios - 缩进自定义表格 View 单元格

标签 ios uitableview storyboard

我使用 Storyboard 创建了一个自定义的 UITableViewCell。该单元格包含 3 个 UILabel 项。当点击编辑按钮时。 (-) 符号在左侧滑入,但单元格没有缩进,并且 (-) 符号覆盖了其中一个 UITextLabel。

我想知道在点击编辑按钮时使所有 3 个 UITextLabels 缩进的最佳方法是什么。我尝试将 3 个标签添加到 UIView (contentView) 并将其添加到 contentsView:

-(void)layoutSubviews {

[super layoutSubviews];
[self.contentView addSubview:self.theContent];

}

尽管这会呈现相同的结果。有什么建议吗?

最佳答案

内容的框架是什么?您是否尝试过修改框架(从“x”值中减去您希望它缩进的数量)?您甚至可以在漂亮的动画中执行此操作:

[UIView beginAnimations : @"cell edit" context:nil];
[UIView setAnimationDuration:1];

CGRect frame = theContent.frame;
frame.origin.x -= 40; // add or subtract here however much you want to indent and in which direction
theContent.frame = frame;   

[UIView commitAnimations];

关于ios - 缩进自定义表格 View 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11265963/

相关文章:

ios - 当我在 Xcode 上移动屏幕时,为什么我看到文本较晚?

ios - 如何从现有的 iPhone 项目中删除 Storyboard

iphone - 如何将 NSCachedURLResponse 传递给解析器委托(delegate)?

ios - 如何在我的选项卡栏应用程序 (iPad) 中创建 UISplitViewController?

iphone - 新版本App内购

ios - 更改 UIImagePicker 纵横比

ios - 分组的UITablleview不可编辑单元格缩进

iOS 11 动画大标题显示模式

iphone - iOS 7、UITableView 和不正确的分隔线

ios - 从一个 View Controller 切换到另一个 View Controller 的推荐方法是什么?