基本上我有这个UItableview,生成时由2个单元组成:一个有分数,如果你触摸另一个,它会插入另一行分数.所有这一切都很好但是当我滚动并且第一个单元格离开屏幕时,当它返回时它会在它上面添加另一个(它叠加它)!我想我做错了什么与dequeueReusableCellWithIdentifier和addSubview,但我无法弄清楚它是什么?
这是我的代码:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
int feedIndex = [indexPath indexAtPosition:[indexPath length] - 1];
static NSString *CellIdentifier1 = @"Cell1";
static NSString *CellIdentifier2 = @"Cell2";
if (feedIndex == 0)// configures the first cell
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier1];
textField1 = [[UITextField alloc] initWithFrame:CGRectMake(0, (44 - 15) / 2.0, 80, 15)];
textField1.font = [UIFont boldSystemFontOfSize:15];
textField1.tag = i+1;// to keep track of the …Run Code Online (Sandbox Code Playgroud)