117
edits
(Created page with "== Introduction== === Required images=== Here you find a customizable PickerView, which is limited to text. You need at least 4 pictures for the pickerView: - a backgroundView fo...") |
m (→PickerView.h) |
||
| (6 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
=== Required images=== | === Required images=== | ||
Here you find a customizable PickerView, which is limited to text. You need at least 4 pictures for the pickerView: | Here you find a customizable PickerView, which is limited to text. You need at least 4 pictures for the pickerView: | ||
* a backgroundView for the whole picker | |||
* a backgroundView for every picker item | |||
* an image for the selected item in the picker item | |||
* an overlay image for the picker item, you can use this, to darken the top most and bottom most elements | |||
[[UIImage]] (Some hints for the images) | |||
=== Required objects === | === Required objects === | ||
* Titles for every picker item (The PickerView can have multiple pickers) as NSStrings in an NSArray | |||
* items, which should be in a picker item (As a NSArray of NSStrings, stored in a NSDictionary, the keys should be equal to the titles) | |||
* the frame for every picker item (As a CGRect stored as a NSValue in a NSArray) | |||
* selected items in every picker item (As a NSNumber stored in a NSArray) | |||
* the height of every item in the picker item | |||
For example with two pickers in the pickerView: | For example with two pickers in the pickerView: | ||
| Line 60: | Line 61: | ||
/* Method sets the background views for the pickers | /* Method sets the background views for the pickers | ||
bgViews an array of background views for the pickers | bgViews an array of background views for the pickers | ||
YOU should have for every Picker one background view | |||
*/ | |||
-(void) setBackgroundViews: (NSArray*) bgViews; | |||
/* Method sets the selected background views for the pickers | |||
bgViews an array of selected background views for the pickers | |||
YOU should have for every Picker one background view | YOU should have for every Picker one background view | ||
| Line 107: | Line 116: | ||
@end | @end | ||
</source> | </source> | ||
=== PickerView.m === | === PickerView.m === | ||
<source lang="objc"> | <source lang="objc"> | ||
| Line 151: | Line 161: | ||
/* Method sets the background views for the pickers | /* Method sets the background views for the pickers | ||
bgViews an array of background views for the pickers | |||
YOU should have for every Picker one background view | |||
*/ | |||
-(void) setBackgroundViews: (NSArray*) bgViews{ | |||
//If bgViews count is not equal to the picker view count | |||
if ([bgViews count] !=[self.titleArray count]) { | |||
return; | |||
} | |||
for (int i=0; i<[self.titleArray count]; i++) { | |||
UIView* newView=[bgViews objectAtIndex:i]; | |||
if (!newView) { | |||
return; | |||
} | |||
int index=10004+i*10; | |||
UIView* v=[self.baseView viewWithTag:index]; | |||
newView.frame=v.frame; | |||
[v.superview insertSubview:newView belowSubview:v]; | |||
[v removeFromSuperview]; | |||
} | |||
} | |||
/* Method sets the selected background views for the pickers | |||
bgViews an array of background views for the pickers | bgViews an array of selected background views for the pickers | ||
YOU should have for every Picker one background view | YOU should have for every Picker one selected background view | ||
*/ | */ | ||
-(void) setSelectedBackgroundViews: (NSArray*) bgViews{ | -(void) setSelectedBackgroundViews: (NSArray*) bgViews{ | ||
| Line 499: | Line 533: | ||
</source> | </source> | ||
[[Category:IOS | [[Category:IOS]] | ||
[[Category:Cocoa]] | |||
[[Category:IPad]] | |||
[[Category:IPhone]] | |||
[[Category:IPodTouch]] | |||
[[Category:Mobile Development]] | |||
[[Category:Objective-C]] | |||
[[Category:Programmiersprachen]] | |||
edits