UITableViewCell调整宽度(转)
http://blog.seymourdev.com/?p=712
UITableViewCell调整宽度
首先先说一下, 这个渣渣是不管用的:
|
1
|
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath; |
这个需要自己写一个UITableViewCell的子类然后把setFrame给override掉. 就像这样:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
@interface LeftMarginTableViewCell : UITableViewCell@end@implementation LeftMarginTableViewCell- (void)setFrame:(CGRect)frame{ frame.origin.x += 120; frame.size.width -= 120; [super setFrame:frame];}@end |
搞定. 然后, 然后就木有然后了.
好吧, 苹果的框架对于开发者大多时候都是灰常灰常人性化的. 但是需要做某些特殊的东西的时候, 我真心觉得这个比让网站兼容IE还烦人.
http://blog.sina.com.cn/s/blog_9ca91e4a0100xlve.html
在自定义CELL中加入此方法:
{
[super layoutSubviews];
if ([super isEditing]) {
//编辑时的需要的frame
}else {
//取消编辑时的需要的frame
}
}