2012-07-16 167 views
1

你好,我正在使用一个库。它有一些嵌入枚举的选项,但我不知道如何配置它们。该图书馆被称为PPRevealSideViewController。 它有一个属性:更改枚举类型值

@property (nonatomic, assign) PPRevealSideOptions options; 

这里是枚举代码:

enum { 
    PPRevealSideOptionsNone = 0, 
    PPRevealSideOptionsShowShadows = 2 << 1, /// Disable or enable the shadows. Enabled by default 
    PPRevealSideOptionsBounceAnimations = 1 << 2, /// Decide if the animations are boucing or not. By default, they are 
    PPRevealSideOptionsCloseCompletlyBeforeOpeningNewDirection = 1 << 3, /// Decide if we close completely the old direction, for the new one or not. Set to YES by default 
    PPRevealSideOptionsKeepOffsetOnRotation = 1 << 4, /// Keep the same offset when rotating. By default, set to no 
    PPRevealSideOptionsResizeSideView = 1 << 5, /// Resize the side view. If set to yes, this disabled the bouncing stuff since the view behind is not large enough to show bouncing correctly. Set to NO by default 
}; 
typedef NSUInteger PPRevealSideOptions; 

非常感谢您!

回答

2
obj.options = opt0 | opt1 | ... etc 

例如:obj.options = PPRevealSideOptionsBounceAnimations | PPRevealSideOptionsResizeSideView;

+0

我还是不明白。例如,如何将PPRevealSideOptionsBounceAnimations更改为0,以便我可以关闭弹跳? – Devfly 2012-07-16 09:02:20

+0

选项存储在int中,并采用像'11001000' - 这对应于PPRevealSideOptionsShowShadows + PPRevealSideOptionsBounceAnimations + PPRevealSideOptionsResizeSideView。所以你应该把这个int改为'10001000'。因此,您只需使用按位操作来更改具体位的值,即可创建'obj.options = obj.options&〜PPRevealSideOptionsBounceAnimations'。 – 2012-07-16 09:08:01

+0

按位运算符真的吗?这是非常低级的解决方案。它确实有效,但现在我的影子与其他选项一起消失了。 – Devfly 2012-07-16 16:23:12

1

我在此控制器用于该目的的一个文档。那么,我的坏,这种方法不是很突出,但确实存在: 您可以使用- (void) resetOption:(PPRevealSideOptions)option;(后面,它是低级别:_options ^= option;) 或使用- (void) setOption:(PPRevealSideOptions)option设置一个选项。甚至有一个setOptionS方法;)