UIView 框架设置错误,视图的原点为 {nan, nan}。
这是我的代码的一部分。
NSLog(@"fr: %@", NSStringFromCGRect(frame_)); NSLog(@"org: %@",
NSStringFromCGPoint(frame_.origin)); // cell.frame = frame_; [cell
setFrame: frame_];
NSLog(@"c: %@", cell); NSLog(@"c frame: %@",
NSStringFromCGRect(cell.frame));
打印出来的结果令人惊讶。有人对此有任何想法吗?帮助和感谢。
[657:707] fr: {{350, 600}, {175, 300}}
[657:707] org: {350, 600}
[657:707] c: <JXUIGridViewCell: 0xf62d3c0; frame = (nan nan; 175 300); tag = 4010; animations = { position=<CABasicAnimation: 0x15b4a0>; bounds=<CABasicAnimation: 0x15b540>; }; layer = <CALayer: 0xf62d400>>
[657:707] c frame: {{nan, nan}, {175, 300}}
This is part of my code.
NSLog(@"fr: %@", NSStringFromCGRect(frame_)); NSLog(@"org: %@",
NSStringFromCGPoint(frame_.origin)); // cell.frame = frame_; [cell
setFrame: frame_];
NSLog(@"c: %@", cell); NSLog(@"c frame: %@",
NSStringFromCGRect(cell.frame));
And the printouts are surprising. Anyone got any idea on this? help and thanks.
[657:707] fr: {{350, 600}, {175, 300}}
[657:707] org: {350, 600}
[657:707] c: <JXUIGridViewCell: 0xf62d3c0; frame = (nan nan; 175 300); tag = 4010; animations = { position=<CABasicAnimation: 0x15b4a0>; bounds=<CABasicAnimation: 0x15b540>; }; layer = <CALayer: 0xf62d400>>
[657:707] c frame: {{nan, nan}, {175, 300}}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上我也在寻找这个问题的答案。但还是不够。
但事实证明,如果您在任何时候将视图的原点设置为 nan,那么它就会保留。因此它永远不能再改变。
解决方案:切勿将视图原点设置为 nan。
I was actually looking for an answer for this very problem as well. But came up short.
But it turns out, that if you at any point set the origin of a view to nan, then it will stick. Thus it can never be changed again.
Solution: Never set origin of view to nan.