[問題] UIView autoresize後位置以及大小錯誤!

看板MacDev作者 (刻骨銘心...)時間12年前 (2012/05/07 11:54), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
有個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
文章代碼(AID): #1FfqT-C1 (MacDev)