PTT
Submit
Submit
選擇語言
正體中文
简体中文
PTT
MacDev
Re: [問題] Autolayout使用問題
作者:
whitefur
(白毛)
2014-02-12 09:59:54
※ 引述《kiii210 (JohnnyChian)》之銘言:
: 大家好,上來請教一下各位高手...小弟在Autolayout使用上一直都很有困難
: 現在是用StoryBoard拉Autolayout
: 畫面上有一個 "searchBar" 跟 "tableView" 排列方式如圖
: http://i.imgur.com/RrlzpSr.png
: searchBar的constraint是Bottom Space to tableView, 距離0
: tableView的constraint是Top Space to tableView, 距離0
: 另外也有Leading space 跟 Trailing Space to Superview, 距離也都是0
: 現在有個需求, 有某個狀況會要把searchBar從畫面中移除(removeFromSuperView)
: 而我想要在searchBar移除之後讓tableView的Top Space to Superview 是 0
: 簡單的說就是searchBar移除之後, tableView要往上遞補..
: 不過一直試不出來, 也不知道constraint怎麼設比較好
: 不知道searchBar移除之後, 該怎麼讓autolayout知道我想重新layout @@
: 麻煩一下各位高手了 謝謝
設一個讓tableView的top跟superview的bottuom距離為0的constraint即可
^^^^我寫錯了,是top
[self.view addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[tableView]"
options:0
metrics:nil
views:@{@"tableView": _tableView}]];
我寫了一個簡單的Demo
https://github.com/WhiteFur/AutolayoutPractice
作者:
kiii210
(HelloWorld!)
2014-02-12 12:25:00
感謝您,成功了,我之前也是這樣想...但不是用visualFormat我這樣寫:
http://goo.gl/hN2Fa7,意思應該一樣呀?
怎麼會這個就不成功..疑惑..謝謝...我以為是要跟superview的bottom對齊=_=tableview上面跟superview的下面距離是0^以為是
繼續閱讀
[問題] 關於touch event
ef1231
Re: [問題] Applescript utf8 之問題
uranusjr
Re: [問題] 存取相簿的問題
darktt
[問題] 能夠偵測手寫輸入嗎?
GoodTauSo
[問題] Applescript utf8 之問題
KORAS
[問題] app網站同步疑問
haves560
Re: [問題] 請問 IPC - 更改需求至 tcp/ip ; Object C 與 Xcode
HuangJC
[問題] 存取相簿的問題
LonelyLouis
Re: [分享] 給平常也會看 AmiAmi 小人網站的朋友
tomjpsun
[問題] 同網域下傳檔案
issuemylove
Links
booklink
Contact Us: admin [ a t ] ucptt.com