VitalyChuprykVitalyChupryk USMember
edited May 2014 in Xamarin.iOS

Why does this return false on iOS7?

UINavigationBar.Appearance.RespondsToSelector(new Selector("setBarTintColor:"))


  • adamkempadamkemp USInsider, Developer Group Leader mod

    Appearance objects a special proxy objects that take advantage of ObjectiveC runtime magic to pretend to implement methods that don't exist at compile time. In ObjectiveC the return type of the [UINavigationBar appearance] method is UINavigationBar, but the actual runtime type is actually not a UINavigationBar. It just pretends to be one by intercepting the method calls. So instead of setting the BarTintColor on an actual navigation bar it just records that setting for later use.

    tl;dr it's magic

    Unfortunately, this also makes it very difficult to do your own custom appearance properties directly in C#. I haven't figured out how to make it work yet, and I'm still not sure whether it's even possible.

  • VitalyChuprykVitalyChupryk USMember

    Ok, then any idea how to do this another way in C#?

    [[UINavigationBar class] instancesRespondToSelector:@selector(setBarTintColor:)]
  • adamkempadamkemp USInsider, Developer Group Leader mod

    Why are you trying to do that? What is your ultimate goal here?

  • VitalyChuprykVitalyChupryk USMember

    Goal is to avoid a crash on iOS6 ;)

  • adamkempadamkemp USInsider, Developer Group Leader mod
  • VitalyChuprykVitalyChupryk USMember

    @adamkemp‌ Thanks!

Sign In or Register to comment.