IOS 6 UITableViewCellEditingStyle重叠TableViewCell标签

时间:2012-11-09 14:09:50

标签: ios6

我正在使用IOS 6 UITableView,我的问题是每当我将表视图置于编辑模式时,deletestyle(UITableViewCellEditingStyleDelete)的表视图单元格旁边出现的编辑控件会重叠两个标签(xyzname和xyzcollege)。 我在IOS 5中没有这个问题(使用相同的代码)。

CODE:

    - (void)viewDidLoad
     {
         [super viewDidLoad]; 
         NSString *path = [[NSBundle mainBundle]pathForResource:@"friends"ofType:@"plist"];

         NSDictionary *xyz = [[NSDictionary alloc]initWithContentsOfFile:path];

         _names = [xyz objectForKey:@"name"];
         _colls = [xyz objectForKey:@"college"];

         self.navigationItem.rightBarButtonItem = self.editButtonItem;

     }

     -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
     {
         NSInteger count =_names.count;
         if(self.editing)
         {
             count++;
         }
         return count;
     }

    -(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:         (NSIndexPath *)indexPath
    {
         saumyaTableViewCell *cell;

         cell = [_saumyaTable dequeueReusableCellWithIdentifier:@"saumyacell"];

         if(indexPath.row < _names.count)
         {
            cell.xyzname.text = [_names objectAtIndex:indexPath.row];
            cell.xyzcollege.text = [_colls objectAtIndex:indexPath.row];
         }
         else
         {

            cell.xyzname.text = @"Add name.";
            cell.xyzcollege.text = @"Add College";
            cell.editingAccessoryType =
            UITableViewCellAccessoryDisclosureIndicator;
         }
         return cell;
    }


   -(void)setEditing:(BOOL)editing animated:(BOOL) animated
   {

      if( editing != self.editing )
      {
          [super setEditing:editing animated:animated];
          [_saumyaTable setEditing:editing animated:animated];

          NSArray *indexes = [NSArray arrayWithObject:
          [NSIndexPath indexPathForRow:_names.count inSection:0]];

          if (editing == YES )
          {
             [_saumyaTable insertRowsAtIndexPaths:indexes       withRowAnimation:UITableViewRowAnimationLeft];
          }
          else
          {
             [_saumyaTable deleteRowsAtIndexPaths:indexes
                         withRowAnimation:UITableViewRowAnimationLeft];
          }
       }
    }

   - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView  editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row < _names.count)
    {
        return UITableViewCellEditingStyleDelete;
    }
    else
    {
        return UITableViewCellEditingStyleInsert;
    }
 }

图片描述:

1.UITableViewCell有两个标签(xyzname和xyzcollege)

2.UITableViewCellEditingStyleDelete在单元格进入编辑模式时重叠这两个标签

如果我希望这些标签在我的视图进入编辑模式时自动在右侧动画,并在退出编辑模式后再次动画显示原始位置,该怎么办?

谢谢你

0 个答案:

没有答案