[英]Set delegate of objects to nil which are assigned to self in cellforrowatindexpath
我的應用程序中有一個自定義控件,說CustomControl
。 我在View Controller的tableview中使用的每個自定義UITableViewCell
都使用了此控件。
在某些情況下,我想將我的CustomControl的狀態通知給View Controller。 因此,我為CustomControl創建了協議,並希望View Controller進行通知,因此我將customCell.customControl.delegate = self;
分配給了我customCell.customControl.delegate = self;
在我的cellForRowAtIndexPath
。
現在,我想將視圖控制器的dealloc
中所有自定義單元的委托設置為nil。 誰能告訴我該怎么做?
假設您始終在cellForRowAtIndexPath
方法中設置自定義控件的委托,則可以在CustomCell類中嘗試以下操作:
- (void)prepareForReuse
{
[super prepareForReuse];
self.myCustomControl.delegate = nil;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.