내 iPhone 응용 프로그램에 대한 사용자 정의 테이블 셀을 Monodevelop 및 xcode 4를 기반으로 모노 터치를 기반으로 만들고 싶습니다. 나는이 같은 클래스를 생성이이 기사에 의해monodevelop 및 Xcode를 사용하여 사용자 정의 표 셀 만들기
http://slodge.blogspot.co.uk/2013/01/uitableviewcell-using-xib-editor.html
을 : 나는이 기사를 발견
[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
및 정의 아울렛을 설계했습니다.
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;
}
지금, 응용 프로그램이 잘 구축,하지만 난 실행할 때 debuger이 라인에 오류를 가져옵니다 :
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'
그럼 내
GetCell
방법으로이 같은 코드를 사용
Realy 나는 이것을 모릅니다. 내가 그것을 삭제할 때. 응용 프로그램은 내 ListingCell
클래스의 셀 객체와 arror를 만듭니다. 인터넷에서 많은 검색을 수행했지만 해결책을 찾지 못했습니다. 어떤 몸이라도 이것에 대해 어떤 생각을 가지고 있습니까?
프로그래밍 방식으로 사용자 지정 셀을 만들 수 있음을 알게되었습니다. 작동하지만 문제는 런타임에 프로그래밍 방식으로 어려운 셀을 만드는 것이 어렵다는 것입니다. excode로이 세포를 만드는 것은 간단하지만 왜 작동하지 않는지 알지 못합니다. -S
답장을 보내 주셔서 감사합니다. 그것은 나를 위해 일하지 않습니다. 내가 변경할 때 'cell = (ListingCell) tableView.DequeueReusableCell (식별자) 'to'cell = (ListingCell) tableView.DequeueReusableCell (identifier, indexPath) '응용 프로그램에서 ivalid 인수 오류가 발생했습니다. 나는 이것을 무시하고 'var views = NSBundle.MainBundle.LoadNib ("ListingCell", cell, null)'을 var view = NSBundle.MainBundle.LoadNib ("ListingCell", 셀, null)로 변경하고 다음 줄을 주석 처리합니다. 이제 응용 프로그램이 실행 시간에 'LocatoinLbl'과 같은 내 목록 객체에 오류가 발생합니다. –
이미지 추가 및 메모리 오류에 관해서. 나는 get cell method에서 신경 써야했다. xamarin lazy table 예제를 기반으로합니다. –
아마도 'LoadNib'메서드에서 사용하는 'nibName'매개 변수 때문일 수 있습니다. 그냥 내 사용자 지정 셀 클래스를 사용합니다. 하지만이 질문에 보이는 것입니다 http://stackoverflow.com/questions/7184206/loading-custom-table-view-cells-from-nib-files?rq=1 대답은이게 다른 일이라고 말하고 있습니다. 'nibName'에 대해 내가 틀렸어? –