作者lab0424 (刻骨铭心...)
看板MacDev
标题[问题] UIView autoresize後位置以及大小错误!
时间Mon May 7 11:54:35 2012
有个ui layout上的问题想请教一下有经验的大大,
问题如下:
有一个parent view: UIViewA size从: 768x1024 resize成508x891
而加在UIViewA上的UIViewB 的size却从768x70 resize成508x0
Hight变成0, 且y的位置也超出UIViewA! (跑到(0,954)的位置上)
请问一下可能是甚麽原因?
code如下:
- (void)loadView
{
UIView *aView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
aView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
aView.autoresizesSubviews = YES;
self.view = [aView autorelease];
bView = [[UIView alloc] initWithFrame:CGRectMake(0.0, self.view.bounds.size.height - 70.0, self.view.bounds.size.width, 70.0)]; bView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
bView.backgroundColor = [UIColor redColor];
[self.view addSubview:bView];
}
不知道遇到甚麽问题为什麽resize後的位置以及大小都跑掉了!
试着把uiviewB的高度调大一点可以看到view了但是位置却是错误的!
想请教一下关於autoresizingMask这个属性该如何正确使用才能使subview
正确的附加在parent view上面呢?
感谢大大们~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.34.53.233