[問題] Custom Cell的幾個問題
各位大大,小弟想請教2個問題:
1.當我 Custom Cell 時,但若到 DetailViewController 去修改Array的內容後 ,
返回上一頁 Cell 顯示的卻還是修改之前的內容,有確認Array的內容無誤
aArray、bArray...等皆為NSMutableArray,請問到底是那裡出錯了??
2.當Cell資料較多時,超出一個頁面所能呈現出的資料,EX:超過21筆 ,將畫面
上下捲動會出現其他資料沒錯,但資料的排序會亂掉,點選亂掉的資料進入
DetailViewController也與Cell所呈現的資料不相符
請問各位到底是什麼問題?找不出原因苦惱中.....
謝謝
Code如下:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
//增加LABEL
UILable *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(105.0, 10, 125, 22.0)];
[aLabel setText:[NSString stringWithFormat:@"%@",[aArray objectAtIndex:indexPath.row]]];
UILable *bLabell = [[UILabel alloc] initWithFrame:CGRectMake(500.0,10.0, 125, 22.0)];
[bLabell setText:[NSString stringWithFormat:@"%@",[bArray objectAtIndex:indexPath.row]]];
UILable *cLabel = [[UILabel alloc] initWithFrame:CGRectMake(360.0, 10, 125, 22.0)];
[cLabel setText:[NSString stringWithFormat:@"%@",[cArray objectAtIndex:indexPath.row]]];
UILable *dLabel = [[UILabel alloc] initWithFrame:CGRectMake(230.0, 10, 125, 22.0)];
[dLabel setText:[NSString stringWithFormat:@"%@",[dArray objectAtIndex:indexPath.row]]];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
[[cell contentView]addSubview:aLabel];
[[cell contentView]addSubview:bLabell];
[[cell contentView]addSubview:cLabel];
[[cell contentView]addSubview:dLabel];
}
return cell;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.241.181.12
推
05/15 09:20, , 1F
05/15 09:20, 1F
→
05/15 09:52, , 2F
05/15 09:52, 2F
→
05/15 09:54, , 3F
05/15 09:54, 3F
推
05/15 10:27, , 4F
05/15 10:27, 4F
→
05/15 10:28, , 5F
05/15 10:28, 5F
→
05/15 10:29, , 6F
05/15 10:29, 6F
推
05/15 12:56, , 7F
05/15 12:56, 7F
→
05/15 12:57, , 8F
05/15 12:57, 8F
→
05/15 12:57, , 9F
05/15 12:57, 9F
→
05/15 12:58, , 10F
05/15 12:58, 10F
→
05/15 13:24, , 11F
05/15 13:24, 11F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):