将UITableViewCell配件放在首位 [英] Keep UITableViewCell accessory on top
本文介绍了将UITableViewCell配件放在首位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有附件类型详细指示符的UITableViewCell。当我调整单元格的大小时,单元格附件会自动居中。如何让它保持在最顶层,而不是居中?
I have a UITableViewCell with a accessorytype detail indicator. When I resize the cell, the cells accessory centers itself horizontally. How can I make it stay on top, and not center itself?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
customCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID" forIndexPath:indexPath];
return cell;
}
如果可能,我更喜欢在故事板中进行,如果没有,我很高兴听到如何以编程方式进行。
我试过这样做:
I'd prefer doing it in the storyboard if possible, if not, I'm happy to hear how to do it programatically.
I tried doing like this:
CGRect accessoryFrame = cell.accessoryView.frame;
accessoryFrame.origin.y = 10;
cell.accessoryView.frame = accessoryFrame;
但它没有用。
But it didn't work.
推荐答案
您必须创建一个自己的附件单元作为子视图并将其放置在该位置。使用Autolayout。
you must create a own accessory cell as subview and position it on the place. Use Autolayout.
这篇关于将UITableViewCell配件放在首位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文