我有一個擴展UITableViewCell的自定義類。它有兩個標籤和一個UISegmentedControl。爲什麼我的自定義UITableViewCell永不改變原型?
這是我配置的cellForRowAtIndexPath()。當我在調試器中檢查「單元」時,它具有我提供的所有數據。但不知何故數據從未得到應用。目前
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
CustomGameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[CustomGameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
MyData *my_data = [rows objectAtIndex:indexPath.row];
UILabel *my_date = [[UILabel alloc] init];
my_date.text = my_data.myDate;
[cell setMyDateLabel:my_date];
UILabel *my_question = [[UILabel alloc] init];
my_question.text = my.question;
[cell setMyQuestionLabel:my_question];
UISegmentedControl *my_choices = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObjects:my.firstChoice, my.secondChoice, nil]];
[my_choices setSelectedSegmentIndex:my.choice];
[cell setMyChoiceSegments:my_choices];
return cell
}
,我想顯示的數據是在一個數組我viewDidLoad中(創建),其通過「行」 var爲至的cellForRowAtIndexPath()訪問。
當我在模擬器中運行代碼時,我在表中得到了三行,代表我在viewDidLoad()中創建的數組中的三個元素。但是,這些行的內容與我在故事板中定義的完全一樣。
我錯過了什麼?
我會試試看。但是,我需要使用autorelease與ARC? –
@DarrellBrogdon你沒有。 Shekhar顯然認爲你沒有使用ARC。 (我不知道爲什麼任何人現在都不會只使用ARC!) – Rob