我的自定义TableViewCell在storyboard中定义了一个带有框架的imageView(195,16; 95,25)
但是当我尝试在运行时访问该帧时,它会为所有出口返回(0,58,0,0),不仅仅是imageView,还有UILabels。
//CustomTableViewCell subclass
- (void)layoutSubviews{
[super layoutSubviews];
NSLog(@"%@", self.fiveStartForeground);
}
这来自控制台:
2012-09-27 18:57:46.563 200Pomodoros[11395:c07] <UIImageView: 0x7599640; frame = (0 58; 0 0); clipsToBounds = YES; opaque = NO; autoresize = TM+BM; layer = <CALayer: 0x759a0d0>>
但过了一会儿,它又恢复正常了:
2012-09-27 18:58:48.025 200Pomodoros[11395:c07] <UIImageView: 0x7599640; frame = (195.5 16; 94.5 25); clipsToBounds = YES; opaque = NO; autoresize = TM+BM; layer = <CALayer: 0x759a0d0>>
我需要更改
中的图像框(宽度)- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
所以它看起来像是一个5开始评级的东西。 但我得到的框架是错误的。(0,58,0,0)...
答案 0 :(得分:1)
这是iOS6的愚蠢AutoLayout ...禁用它,你很高兴。
答案 1 :(得分:0)
可能是第一次没有完全设置用户界面,所以你过早地询问它的值?
答案 2 :(得分:0)
你可以使用like ..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.YourImageView.frame = CGRectMake(195.5, 16, 94.5, 25); // Or what you want to set
我希望这对你有用..