Tôi đang sử dụng Xcode 6 và tôi đã tạo ứng dụng của mình với UITableView
và custom Cell
trong đó. Đây là tôi custom cell
Gán đối tượng được giữ lại cho thuộc tính yếu
@interface SuggestingTableViewCell : UITableViewCell
@property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesOne;
@property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesTwo;
@property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesThree;
@property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesFour;
@end
Như bạn có thể thấy tôi có bốn IBOutets
đến một SuggestedSeriesView
đó là một lớp con của UIView
. Trong TableView DataSource
phương pháp tôi đã tạo ra những SuggestedSeriesView
và gán chúng thích:
cellIdentifier = suggestionCell;
SuggestingTableViewCell *suggesting = (SuggestingTableViewCell *)[tableView dequeueReusableCellWithIdentifier:suggestionCell];
Series *ser1 = series[0];
suggesting.seriesOne = [[SuggestedSeriesView alloc] initWithFrame:suggesting.seriesOne.bounds
andSeriesData:@{JV_SERIES_IMAGE_URL : ser1.imageURL,
JV_SERIES_TITLE : ser1.title}];
Series *ser2 = series[1];
suggesting.seriesTwo = [[SuggestedSeriesView alloc] initWithFrame:suggesting.seriesTwo.bounds
andSeriesData:@{JV_SERIES_IMAGE_URL : ser2.imageURL,
JV_SERIES_TITLE : ser2.title}];
Series *ser3 = series[2];
suggesting.seriesThree = [[SuggestedSeriesView alloc] initWithFrame:suggesting.seriesThree.bounds
andSeriesData:@{JV_SERIES_IMAGE_URL : ser3.imageURL,
JV_SERIES_TITLE : ser3.title}];
Series *ser4 = series[3];
suggesting.seriesFour = [[SuggestedSeriesView alloc] initWithFrame:suggesting.seriesFour.bounds
andSeriesData:@{JV_SERIES_IMAGE_URL : ser4.imageURL,
JV_SERIES_TITLE : ser4.title}];
Trình biên dịch mang lại cho tôi những cảnh báo rằng:
Gán đối tượng giữ lại để sở hữu yếu; đối tượng sẽ được phát hành sau khi phân
Tại sao điều này đang xảy ra với SuggestedSeriesView
bị giữ lại bởi các cell
vì nó không có IBOutlet
?
Cảm ơn sự giúp đỡ.
Không, nó không phải là và đó là chính xác điểm. Việc giữ lại không xảy ra vì nội dung là 'IBOutlet' nhưng vì nội dung là' strong'. –