看板 MacDev 關於我們 聯絡資訊
之前沒寫過UItableView, 這幾天第一次嘗試的時候卻一直碰到瓶頸。 照著網路上的資料一步步實作卻一直無法成功顯示出text, 在網路上找了好久仍然找不到原因及方法, 以下是我的程式碼 #import "NextViewController.h" @implementation NextViewController - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:\ (NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"any\ -cell"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentif\ ier:@"any-cell"] autorelease]; } cell.textLabel.text = @"test"; return cell; } @end 一開始我是使用cell.setText來處理,但是OS 3.0後好像就不能使用了, 於是改用cell.textLable.text,可以執行但是卻無法顯示, 一直無法找出原因, 可以請提醒我哪個部份的觀念有錯誤嗎? 謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.236.106
uranusjr:最後面改用 [NSString stringWithString:@"test"] ? 10/06 02:21
uranusjr:唔, 我把你的 method 拿去複製貼上一個全新的 Navigation 10/06 02:28
uranusjr:based Application 執行無誤...你可能要檢查其他的地方 10/06 02:28
leetzuwen:我不是用navigation而是用一個UItableViewController 10/06 02:37
leetzuwen:問題是出在這邊嗎? 10/06 02:37
aecho:initWithFrame在 OS 3.0之後就沒在用了~~ 10/06 07:57
aecho:改用 initWithStyle 10/06 07:57
aecho:啊~~ 我看到cell在alloc時,多了一個autorelease... 10/07 07:14
aecho:這邊要加autorelease嗎?印象中我都沒加過 XDD 10/07 07:15
zonble:要加 10/07 23:55
zonble:不加會 memory leak 10/07 23:55