Re: [問題] 請問關於navigation bar??
※ 引述《zonble (zonble)》之銘言:
: ※ 引述《valda (valda)》之銘言:
: : 請問如何在navigation bar 上加上一個textfield
: : 感謝
: : 試了很多次都不太行
: UITextField *aTextField = [[UITextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 40.0)];
: aTextField.borderStyle = UITextBorderStyleRoundedRect;
: aTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
: aTextField.placeholder = @"Type something here";
: self.textField = [aTextField autorelease];
: self.navigationItem.titleView = self.textField;
想借用此文章問一下zonble前輩一個小問題,是關於autorelease的。
以上例來說,如果第一行寫的是
UITextField *aTextField = [[[UITextField alloc] initWithFrame...] autorelease];
第五跟第六行寫的是
self.textField = aTextField;
self.navigationItem.titleView = aTextField; (或 _textField)
這兩種寫法的差距有高下之分嗎?
因為我自己是都使用第二種寫法,很想知道只靠這招是否有問題?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.99.52
→
02/23 01:26, , 1F
02/23 01:26, 1F
→
02/23 20:02, , 2F
02/23 20:02, 2F
→
02/23 21:19, , 3F
02/23 21:19, 3F
→
02/23 21:19, , 4F
02/23 21:19, 4F
→
02/23 22:36, , 5F
02/23 22:36, 5F
→
02/24 15:58, , 6F
02/24 15:58, 6F
→
02/24 15:59, , 7F
02/24 15:59, 7F
→
02/24 15:59, , 8F
02/24 15:59, 8F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 4 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章
14
39