Three20&MonoTouch:TTTabStrip变色不起作用

问题描述:

我创建了一个继承自TTDefaultStyleSheet的新类。Three20&MonoTouch:TTTabStrip变色不起作用

public class BlackStyleSheet : TTDefaultStyleSheet 
{ 
    public BlackStyleSheet() : base() 
    { 
     Console.WriteLine("BlackStyleSheet created."); 
    } 

    public override UIColor TabBarTintColor 
    { 
     get 
     { 
     Console.WriteLine("BlackStyleSheet.TabBarTintColor returned."); 
      return UIColor.Black; 
     } 
    } 

    [Export ("tabTintColor")] 
    public override UIColor TabTintColor 
    { 
     get 
     { 
      Console.WriteLine("BlackStyleSheet.TabTintColor returned."); 
      return UIColor.Black; 
     } 
    } 
} 

我在FinishedLaunching方法中将此自定义样式表设置为默认值。

public override void FinishedLaunching (UIApplication application) 
{ 
    Three20.TTStyleSheet.GlobalStyleSheet = new BlackStyleSheet(); 
    Three20.TTDefaultStyleSheet.GlobalStyleSheet = new BlackStyleSheet(); 
    Console.WriteLine("Three20 style sheet set."); 
} 

然后,我创建自己的自定义的UIViewController的viewDidLoad()方法中的实际TTTabStrip和TTTabItem元素。 TTTabItem对象在类级而不是方法级声明。

tab1 = new TTTabItem("1"); 
tab2 = new TTTabItem("2"); 
tab3 = new TTTabItem("3"); 
TabStrip = new TTTabStrip(); 
TabStrip.Frame = new RectangleF(0,0,View.Frame.Width, 44); 
TabStrip.TabItems = NSArray.FromNSObjects(tab1,tab2,tab3); 
TabStrip.SelectedTabIndex = 0; 
View.AddSubview(TabStrip); 

当TTDefaultStyleSheet.GlobalStyleSheet属性设置为新的自定义样式表,应用程序崩溃。当此属性设置被删除时,该应用程序运行完美,但标签条仍为灰色。

在我读过的所有论坛中(似乎都不是MonoTouch特有的),它们都表明创建自己的样式表,然后将其设置为全局样式表是最好的选择。但是这对MonoTouch来说似乎不适用。

有没有人有任何想法?

谢谢

约翰K.

+0

我刚刚遇到这个问题我自己,你有没有解决它? – Eric 2013-05-15 00:59:16

我想你的例子在XCode中与Objective-C和我可以证实,这此方法确实工作。我也尝试过使用MonoTouch,并看到了相同的结果。

我发现在过去的Three20绑定代码中有几个问题似乎会导致这样的异常终止。您可以尝试修复现有的绑定代码,或手动创建您需要从Three20中获得的绑定。

http://docs.xamarin.com/ios/advanced_topics/binding_objective-c_types

+0

我也看到了同样的崩溃,希望有人会在这里解决问题。 – Eric 2013-05-15 11:36:10