2012-07-16 163 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方法;)