2012-08-26 122 views
1

爲什麼不能更改MonoTouch.Dialog.TableView.Background顏色?我正在使用MonoTouch.Dialog的Elements API。它仍然是灰色的!爲什麼不能更改Monotouch.Dialog.TableView.Background顏色

class MyDialogViewController : DialogViewController { 

public MyDialogViewController (RootElement root) : base (root) 
{ 
} 

public override void LoadView() 
{ 
    base.LoadView(); 
    TableView.BackgroundColor = UIColor.Clear; 
    UIImage background = UIImage.FromFile ("Mybackground.png"); 
    ParentViewController.View.BackgroundColor = UIColor.FromPatternImage (background); 
} 
} 


public partial class MyVC: UINavigationController 
{ 
    public void CreateTestUI() 
    { 

      var menu = new RootElement("MyMenu"){ 
      new Section ("test"){ 
       new StringElement("Test", delegate() { }), ... 

     var dv = new MyDialogViewController (menu) { 
      Autorotate = true 
     }; 

     // add the nav controller to the window 
     this.PushViewController (dv, true); 
     } 
    } 

回答

6
在iPad上

,必須加入這一行:TableView.BackgroundView = null;

現在它工作得很好,感謝poupou,感謝所有。

public override void LoadView() 
    { 
     base.LoadView(); 
     TableView.BackgroundView = null; 
     TableView.BackgroundColor = UIColor.Black; 
    }