Re: [問題] viweDidUnload該填的內容為何?

看板MacDev作者 (星空下的鮪魚)時間16年前 (2009/08/05 09:49), 編輯推噓1(1011)
留言12則, 3人參與, 最新討論串4/4 (看更多)
※ 引述《denru01 (阿儒)》之銘言: : [cell.contentView addSubview:textField]; 查到的addSubView,他會做retain的動作,而在removeFromSuperview時會做release。 addSubview: Adds a view to the receiver’s subviews so it’s displayed above its siblings. - (void)addSubview:(UIView *)view Discussion This method also sets the receiver as the next responder of view. The receiver retains view. If you use removeFromSuperview to remove view from the view hierarchy, view is released. If you want to keep using view after removing it from the view hierarchy (if, for example, you are swapping through a number of views), you must retain it before invoking removeFromSuperview. Availability * Available in iPhone OS 2.0 and later. -- 或許人生是一段整合內在的自己 並尋求人間一點真情的過程吧 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.59.242

08/05 10:13, , 1F
波我剛回頭看了一下,你應該不是因為textField crash
08/05 10:13, 1F

08/05 10:13, , 2F
而是因為cell
08/05 10:13, 2F

08/05 10:13, , 3F
把cell的autorelease拿掉吧
08/05 10:13, 3F

08/05 10:14, , 4F
更正,上面當我沒說,沒看到if....= =
08/05 10:14, 4F

08/05 11:21, , 5F
因為我只要一加[textField release]就會crash
08/05 11:21, 5F

08/05 11:22, , 6F
錯誤訊息又說似乎是送信息給已被釋放的物件
08/05 11:22, 6F

08/05 12:01, , 7F
@property(nonatomic, assign) ---會不會是這個問題?
08/05 12:01, 7F

08/05 12:02, , 8F
TextField release時,應該會同時release delegate,
08/05 12:02, 8F

08/05 12:02, , 9F
因此有可能造成release兩次.
08/05 12:02, 9F

08/05 12:03, , 10F
你可以做個實驗,將delegate設成別人,而非self.
08/05 12:03, 10F

08/05 12:04, , 11F
看是不是還會有問題?(記得設完後不要做release動作)
08/05 12:04, 11F

08/05 15:11, , 12F
setDelegate 是不會 retain 的
08/05 15:11, 12F
文章代碼(AID): #1AUEKYcC (MacDev)
文章代碼(AID): #1AUEKYcC (MacDev)