I'm trying to run my app in iOS 7+ versions wherein struck with one issue
I have UIPickerview showing images correctly for versions lessthan iOS 7 but in iOS 7+ entire picker view is messed up. Here's what im trying to achieve
Trying to display same in ViewForRow method. Please check code below
//In ViewDidLoad()
NSArray *box12names = [[NSArray alloc] initWithObjects:@"Black",@"Brown",@"Red",@"Orange",@"Yellow",@"Green",nil];
self.box1_views = [[NSMutableArray alloc] initWithCapacity:10];
// From code below , Box1_Black, Box1_Brown etc... are my png images in APP
for (NSString *str in box12names) {
NSString *filename = [[NSString alloc] initWithFormat:@"Box1_%@.png",str];
UIImage *image = [UIImage imageNamed:filename];
UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[self.box1_views addObject:imageview];
[filename release];
[imageview release];
}
[self.box1_views release];
self.box2_views = [[NSMutableArray alloc] initWithCapacity:10];
for (NSString *str in box12names) {
NSString *filename = [[NSString alloc] initWithFormat:@"Box2_%@.png",str];
UIImageView *imageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename]];
[self.box2_views addObject:imageview];
[filename release];
[imageview release];
}
[self.box2_views release];
[box12names release];
//In PickerViewDelegate method
-(UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
{
NSString *arrayName = [[NSString alloc] initWithFormat:@"box%d_views", component +1];
NSArray *array = [self valueForKey:arrayName];
UIView *tempview = [array objectAtIndex:row];
[arrayName release];
return tempview;
}
//Here my picker view is displaying wierdly with iOS 7+ version whereas works good with iOS 6
Please help
Issue resolved -
{
NSString *arrayName = [[NSString alloc] initWithFormat:@"band%d_views", component +1];
NSArray *array = [self valueForKey:arrayName];
//UIView *tempview = [array objectAtIndex:row];
UIView *tempview=[[UIView alloc] init];
[tempview setBackgroundColor:[UIColor colorWithPatternImage:[[array objectAtIndex:row] image]]];
[arrayName release];
return tempview;
}