iOS 7如何实现UI元素,以便它们看起来不同,具体取决于您编译的SDK? [英] How does iOS 7 implement the UI elements so that they look different depending on what SDK you compile with?

查看:45
本文介绍了iOS 7如何实现UI元素,以便它们看起来不同,具体取决于您编译的SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 7上有一些元素,如 UITableView s, UINavigationBar ,它们具有不同的样式。



此样式在运行时确定,因为这些类是在 UIKit 上实现的,而 UIKit 在运行时动态链接到应用程序,而不是在编译时静态链接。



因此,人们会认为在iOS 7上运行的任何应用都会让这些元素看起来与iOS 7相同。但是,它们保持了以前的风格。在iOS 6上,直到您使用iOS 7 SDK进行编译。除了其中一些(例如 UIAlertView UIMenuController



<我唯一的解释就是他们做了类似的事情:

  #define SDKApplicationWasLinkedAgainst ... 
if(SDKApplicationWasLinkedAgainst< 7.0)
...
else
...

这显然非常麻烦,因为他们需要继续维护很多旧代码。所以我很好奇,这真的是引擎盖下的事情吗?我缺少什么?

解决方案

如果没有太多进入NDA的领域,我只想说是的,他们根据以下调用的结果条件化外观和行为:

  _UIApplicationUsesLegacyUI()

这个函数反过来调用 GSApplicationUsesLegacyUI(),我假设返回基于链接的UIKit版本的结果。



这意味着是的,他们将条件化部分UIKit用于遗留。不确定这是件好事,但这就是他们决定做的事情。


There are elements like UITableViews, UINavigationBars that have a different style on iOS 7.

This style is determined at run time, since those classes are implemented on UIKit, and UIKit is linked with your application dynamically at runtime, not statically at compile time.

So one would think that any app run on iOS 7 would have those elements look the way they look on iOS 7. However, they keep the same style they used to have on iOS 6, until you compile with the iOS 7 SDK. Except for some of them (like UIAlertView or UIMenuController)

My only explanation for this is that they do something kind of like this:

#define SDKApplicationWasLinkedAgainst ...
if (SDKApplicationWasLinkedAgainst < 7.0)
    ...
else
    ...

This is obviously really cumbersome, cause they need to keep maintaining a lot of old code. So I'm curious, is this really what is going on under the hood? What am I missing?

解决方案

Without going too much into NDA'd territory, I'd just like to state that yes, they are conditionalizing appearance and behavior based off of the result from the following call:

_UIApplicationUsesLegacyUI()

This function, in turn, makes a call to GSApplicationUsesLegacyUI(), which I presume returns a result based off of the version of the linked UIKit.

This means that yes, they are conditionalizing parts of UIKit for legacy. Not sure that's a good thing, but that's what they decided to do.

这篇关于iOS 7如何实现UI元素,以便它们看起来不同,具体取决于您编译的SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆