Monodevelop と monotouch に基づく xcode 4 で、iPhone アプリケーション用のカスタム テーブル セルを作成したいと考えています。この記事を見つけました:
http://slodge.blogspot.co.uk/2013/01/uitableviewcell-using-xib-editor.html
この 2 つの記事で、次のようなクラスを作成します。
[Register("ListingCell")]
public partial class ListingCell : UITableViewCell
{
public ListingCell () : base()
{
}
public ListingCell (IntPtr handle) : base(handle)
{
}
public void BindDataToCell(DrivedProperty _property)
{
LocatoinLbl.Text = _property .LocationString ;
}
public void AddImageToCell(UIImage _image){
ListingThumbnail .Image = _image ;
}
}
UITableViewCell
そして、私は自分で定義したアウトレットを設計しました。次に、私のGetCell
方法では、次のようなコードを使用しました。
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
ListingCell cell;
cell = (ListingCell) tableView.DequeueReusableCell (identifier ) ;
if (cell == null) {
cell = new ListingCell ();
var views = NSBundle.MainBundle.LoadNib("ListingCell", cell, null);
cell = Runtime.GetNSObject( views.ValueAt(0) ) as ListingCell;
}
var item = Controller.Items [indexPath.Row];
cell.Tag = indexPath.Row;
cell .BindDataToCell (item );
cell.AddImageToCell ( item .Image);
return cell;
}
これで、アプリケーションは正常にビルドされますが、実行すると、デバッガーで次の行でエラーが発生します。
var views = NSBundle.MainBundle.LoadNib("ListingCell", cell, null);
そして、言います:
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: 'NSBundle </Users/john/Library/Application Support/iPhone Simulator/6.0/Applications/08FFAA89-4AC4-490D-9C1A-4DE4CBC6EBB7/Realtyna_iPhone_Project.app> (loaded)' with name 'ListingCell'
本当にこれは何のためにあるのかわかりません。削ると。ListingCell
アプリケーションは、クラスのセル オブジェクトでエラーを起こします。インターネットで多くの検索を実行しましたが、解決策が見つかりませんでした。これについて何らかの考えを持っている体はありますか?
カスタムセルをプログラムで作成できることがわかりました。それは機能しますが、問題は、実行時にプログラムで難しいセルを作成するのが非常に難しいことです。このセルをexcodeで作成するのは簡単ですが、なぜ機能しないのかわかりません:-S