Re: [問題] tableviewcell的indexPath.row

作者: nobody1 (無事家中坐)   2014-04-02 01:31:53
sample code
if (cell==nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIDT];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
UIImageView *back =[[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 315, 54)];
back.tag = 999;
[cell addSubview:back];
}
UIImageView *thisBack = (UIImageView *)[cell viewWithTag:999];
[thisBack setImage:[UIImage imageName:[mArray objectAtIndex:indexPath.row]]];
有cell就不會再addsubview 舊的拿來把資料換掉
※ 引述《yoyostar1990 (~Yoyo~)》之銘言:
: 用tableviewcell來顯示資料庫資料
: 而每筆資料有個button可以選擇
: 但有default資料
: default資料不想讓他有button
: 不知道要怎麼實現
: 原本是使用indexPath.row > 3 才加button
: 但只有剛進去是正確的
: 上下滑動後全部都會加到button
: 感覺好像是indexPath.row會變動的樣子
: 加上tag也是一樣 滑動後就失敗
: 要怎樣才能固定呢
作者: nobody1 (無事家中坐)   2014-04-02 01:33:00
if(indexPath.rw>3) [XXXX setHidden:YES]

Links booklink

Contact Us: admin [ a t ] ucptt.com