2016-09-22 12 views
0

Google places apiを使用して検索候補を提供しています。それで、すべてのキャラクターがヒットするたびにAPIを検索します。私は更新されたテーブルソースを持っています。ここ は私が、私はこの例外を避けることができる方法はありxamarin iosでUitablesource getcellメソッドでセルを作成するときに例外が発生する

Index was out of range. Must be non-negative and less than the size of the collection. 

高速に値を更新しようとしている例外を取得していますgetcellを方法

public override UITableViewCell GetCell(UITableView tableView,NSIndexPathindexPath) 
{ 
    var cell = base.GetCell(tableView, indexPath) as CityCell; 
    cell.SubscriteToCheckEvent(() => 
{ 
    var ddd = cell as CityCell; 
    viewModel.ZipCode = cell.CityNameText.Text; 
    viewModel.SearchStoresCommand.Execute(true); 
}); 
    return cell; 

} 

のですか?

提案が役に立ちます。

+0

基本クラスとは何ですか?典型的には、基底があなたによって作成された別のクラスでない限り、 'base.GetCell'を呼び出さないでください。独自のクラスから継承していない場合は、 'tableView.DequeueReusableCell'を呼び出してセルを取得する必要があります。 –

答えて

0

「GetCell」メソッドを呼び出す方法が正しくありません。

これはgetcellをするためのサンプルです:

public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath) 
     { 
      MyTableCell cell = tableView.DequeueReusableCell (CellID) as MyTableCell; 
      if (null == cell) { 
       //Init custom cell 
       cell = new MyTableCell (UITableViewCellStyle.Default, CellID); 
       //Bind delete event 
       cell.CellClicked += delegate { 
        //Do something for click event 
       }; 
      } 
      return cell; 
     } 

そして、これは私が他のために書いたのUITableViewのデータ管理についての完全なサンプルである、あなたが見てみる必要があります。

​​

あなたが必要より多くのコードを共有するか、私たちはあなたを助けません。

関連する問題