iPad OUInspector, Slices, Color...
I'm trying to wrap my head around the OUIInspector code and can’t seem to get what I need going. Starting off simple I want to change the background color of a view.
When I init the Inspector I pass it a theView I want to Change. The View has the protocol defined in it and functions for it implemented. When I call up the Inspector with the Color Slice I only see the DetailSlice Navigation swatch, which does nothing when I click it. I'm not 100% sure where the other colors are supposed to come from? Also Looking at the isAppropriate functions, it seems like my view I pass in does not seem to be an appropriate object. How does the Slice get its List of Initial Colors? If I want to Change the Color of more than one Object and want them to each have their own ColorInspectorSlice how do I differentiate the two slices to act upon their respective objects? Any Suggestions? Thanks! |
There are a couple options. The simplest is to have your object conform to OUIColorInspection, use one or more OUIColorInspectorSlices and set/get the appropriate color property for the passed in slice.
You could also subclass OUIAbstractColorInspectorSlice (BackgroundColorInspectorSlice, say) and implement -isAppropriateForInspectedObject: on it to allow your view to be inspected by it. You might require the object to be an instance of your class, or you might just require it to implement -backgroundColor and -setBackgroundColor:. Additionally in your subclass, you'd implement the required subclass methods for OUIAbstractColorInspectorSlice, -getColorsFromObject:, -setColor:forObject:, and -loadColorSwatchesForObject:. Using OUIColorInspectorSlice is probably the simplest, but it isn't the only way. |
Thank you for your reply... Before I break the ColorInspector I tried this out on my newText Inspector. So far its working pretty well.
I've decided to add a key value to the inspectorSlice, then let the object let the inspector slice know if it responds to that key. something like this: [CODE]- (id)initWithKey:(NSString *)newInspectorSliceKey; [/CODE] Then I can call it like: [CODE] [slices addObject:[[[IoUITextInspectorSlice alloc] initWithKey:@"SETitle"] autorelease]]; [slices addObject:[[[IoUITextInspectorSlice alloc] initWithKey:@"SEDescription"] autorelease]]; [/CODE] Then as part of the protocol I have the inspectable object define: [CODE]- (BOOL)objectHasKeyForInspectorSlice:(IoUIInspectorSlice *)inspector { if ([[inspector inspectorSliceKey] isEqualToString: @"SETitle"]){ return YES; } else if ([[inspector inspectorSliceKey] isEqualToString: @"SEDescription"]){ return YES; } return NO; } [/CODE] getting the value for the inspector looks like: (I also have one for the Label) [CODE]- (NSString *)textForInspectorSlice:(IoUIInspectorSlice *)inspector { if ([[inspector inspectorSliceKey] isEqualToString: @"SETitle"]){ return screenTitle; } else if ([[inspector inspectorSliceKey] isEqualToString: @"SEDescription"]){ return screenDescription; } return nil; } [/CODE] setter looks like: [CODE]- (void)setTextValue:(NSString *)newTextValue fromInspectorSlice:(IoUIInspectorSlice *)inspector{ if ([[inspector inspectorSliceKey] isEqualToString: @"SETitle"]){ [self setScreenTitle:newTextValue]; [self createToolbarItems]; } if ([[inspector inspectorSliceKey] isEqualToString: @"SEDescription"]){ [self setScreenDescription:newTextValue]; } } [/CODE]Any Comments would be super! Thanks! |
All times are GMT -8. The time now is 10:22 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.