2016-12-14 18 views
0

iOSが初めてです。私はスワイプでセルを削除するTableViewを作成しています。しかし、私がスワイプするたびに、セルの高さが減少します。私はiOS 10を使用しています。私は以下のコードを使用しています。xamarin iosで毎回セルの高さを削除するスワイプ

コード:

class AppointmentSourceClass : UITableViewSource 
    { 
     List<AppointmentItem> appointments; 

     public AppointmentSourceClass(List<AppointmentItem> appointments) 
     { 
      this.appointments = appointments; 
     } 

     public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) 
     { 
      ApointListCell cell = tableView.DequeueReusableCell(ApointListCell.Key) as ApointListCell ?? ApointListCell.Create(); 
      var item = appointments[indexPath.Row]; 

      cell.BindData(item); 

      cell.Layer.MasksToBounds = false; 
      cell.Layer.CornerRadius = 5.0f; 
      cell.BackgroundColor = UIColor.White; 
      cell.SelectionStyle = UITableViewCellSelectionStyle.None; 

      return cell; 
     } 

     public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) 
     { 
      switch (editingStyle) 
      { 
       case UITableViewCellEditingStyle.Delete: 
        appointments.RemoveAt(indexPath.Row); 
        tableView.DeleteRows(new NSIndexPath[] { indexPath},UITableViewRowAnimation.Fade); 
        break; 
       case UITableViewCellEditingStyle.None: 
        break; 
      } 
     } 

     public override bool CanEditRow(UITableView tableView, NSIndexPath indexPath) 
     { 
      return true; 
     } 

     public override string TitleForDeleteConfirmation(UITableView tableView, NSIndexPath indexPath) 
     { 
      return "Trash ("; 
     } 

     public override nint RowsInSection(UITableView tableview, nint section) 
     { 
      return appointments.Count; 
     } 
    } 
} 

出力:

スワイプイメージ前:

enter image description here

スワイプイメージ後:

enter image description here

答えて

0

が見つかりました。

TableCellで私は2つのtableCellを分離し、それらの間にスペースを作るために以下のコードを使用しています。私はコードを削除する場合、それは正常に動作します。

public override CoreGraphics.CGRect Frame 
     { 
      get 
      { 
       return base.Frame; 
      } 
      set 
      { 
       value.Y += 4; 
       value.Height -= 2 * 4; 
       base.Frame = value; 
      } 
     } 
+0

それで、コードの断片だけでなく、完全な解決策を共有することが重要な理由です:-) –

関連する問題