0

monotouch.dialog를 사용하여 테이블에 대한 사용자 정의 셀을 완성하려고하는데 셀의 세부 텍스트 레이블 색상을 제외하고 거의 모든 것이 정렬되었습니다.MonoTouch - DetailTextLabel 텍스트 색상을 변경하면 NullReferenceException 오류가 발생합니다.

나는이처럼 내 EntryElement 셀을 사용자 정의 할 수 GetCell을 무시하고 :

public class CustomStyledEntryElementPlain : MonoTouch.Dialog.EntryElement 
{ 
    public CustomStyledEntryElementPlain (string _caption, string _value) : base(string.Empty,string.Empty,string.Empty,false) 
    { 
     KeyboardType = UIKeyboardType.Default; 
     Value = _value; 
     ReturnKeyType = UIReturnKeyType.Done; 
     Caption = _caption; 
    } 

    public override UITableViewCell GetCell(UITableView tableView) { 
     var cell = base.GetCell(tableView); 
     cell.BackgroundColor = Resources.XDarkGrayColor; 
     cell.TextLabel.TextColor = Resources.XWhiteColor; 
     cell.BackgroundView = new UIView (RectangleF.Empty); 
     cell.DetailTextLabel.TextColor = UIColor.White; //this line causes the error 

     return cell; 
    } 
} 

나는 다음과 같이 요소를 만들 : 그러나

new CustomSection ("Testing"){ 
       new CustomStyledEntryElementPlain("Test","Test1"), 
       new CustomStyledEntryElementPlain("Test","Test2") 
      }, 

를 테이블 표시에, 나는 오류가 발생합니다 : "System.NullReferenceException이 발생했습니다. 개체 참조가 개체의 인스턴스로 설정되지 않았습니다."

초기에 프로토 타입을 만들었을 때 내가 DetailT extLabel 텍스트 색상 작동! 검은 색 텍스트 (비록 내가 흰색으로 변경하고 싶습니다!)에도 불구하고 내 테이블과 셀의 결과를 변경하는 것은 주석으로 처리됩니다.

누구에게 내가 이것을 얻고 있는지에 대한 아이디어가 있습니까?

답변

0

UITableViewCellDetailTextLabel 속성은 셀에 지원되는 UITableViewCellStyle이있는 경우에만 사용할 수 있습니다. DetailTextLabel property에 대한 UITableViewCell 문서에서 :

UITableViewCell automatically creates the secondary (detail) label if the cell is created with a MonoTouch.UIKit.UITableViewCellStyle that supports a detail label.

If the cell's style doesn't support a detail label, this property returns null.

점검 UITableViewCellStyle에 대한 문서는이 속성을 지원하는 스타일을 찾을 수 있습니다.

+0

고마워요. NilsH - 제가 작업 할 때 다른 셀 스타일을 사용하고 있었을 것입니다. 그리고 저의 삶은 내가 일하는 것을 막기 위해 만든 변화를 기억하지 못했습니다. 문서에서 분명히 다른 스타일을 설명합니다! – Shogan