将objc转换为关于NSDictionaryOfVariableBindings的swift

时间:2015-11-25 11:17:55

标签: objective-c swift

我正在努力实现https://stackoverflow.com/a/17376619/433570

特别是

getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

我见过NSDictionaryOfVariableBindings swift equivalent?

但它对我没有多大帮助,我怎样才能将objc翻译成swift?

1 个答案:

答案 0 :(得分:1)

您只需获取NSDictionaryOfVariableBindings中列出的每个视图,并创建一个包含此视图的常用快速字典,并将变量名称作为键。

示例:

NSDictionaryOfVariableBindings(view1, view2, view3)

将成为

["view1" : view1, "view2" : view2, "view3" : view3]

所以

NSDictionary *views = NSDictionaryOfVariableBindings(subview);

将成为

let views = ["subview" : subview]