2014-06-23 2 views
0

모든 컨트롤이 오른쪽으로 정렬되도록 MonoTouch.Dialog에 대한 사용자 지정 EntryElement를 만들었습니다. 이 대화 상자가 새로 고쳐 때까지 테이블이 스크롤 예를 들어, 잘 작동, 또는 서브 뷰는 다음 기각 제시다시 그리기/새로 고침시 사용자 지정 EntryElement 맞춤 변경

public class RightAlignEntryElement : EntryElement 
{ 
    private NSString _cellKey = new NSString("RightAlignedEntryElement"); 

    public RightAlignEntryElement(string caption, string placeholder, string value) : base(caption, placeholder, value) 
    { 
    } 

    protected override UITextField CreateTextField(RectangleF frame) 
    {  
     var paddedFrame = frame; 
     paddedFrame.Width = frame.Width -= 10; 
     var textField = base.CreateTextField(paddedFrame); 
     textField.TextAlignment = UITextAlignment.Right; 


     return textField; 
    } 

    public override UITableViewCell GetCell(UITableView tv) 
    { 
    var cell = base.GetCell(tv); 
    return cell; 
    } 

    protected override NSString CellKey 
    { 
    get { return _cellKey; } 
    } 
} 

다음과 같이 코드입니다.

셀 오른쪽에 채우기가 있고 스크롤되면 패딩이 사라집니다. 나는 이것이 과거의 문제 였고, 여기와 Xamarin 포럼에 대한 여러 가지 다른 제안을 보았지만 나에게는 아무런 효과가없는 것으로 보인다.

전후에 첨부 된 화면 잡기를 참조하십시오. 당신이

을 RightAlignEntryElement에서 셀 재사용을 사용하지에

동작이 때문이다 : 공식적으로

After

답변

0

Before

, 여기에 나는이 질문에 대한 또 다른 포럼에서 얻은 반응이다

GetCell 방법은 다음과 같아야합니다.

public override UITableViewCell GetCell(UITableView tv) 
{ 
    var cell = tv.DequeueReusableCell (CellKey) as UITableViewCell; 
    if (cell == null) { 
     cell = base.GetCell(tv); 

     cell.TextLabel.Font = UIFont.FromName("HelveticaNeue-Light", 16); 
    } 

    return cell; 
} 
관련 문제