I have created 8 UIViews
, I have a UIPicker
and when the user selects something with the UIPicker
I run the thread though a big if statement which I am not happy about.
I would like to know if what I am doing is okay? and also if the code I am using to load the view is how it should be done.. the code is below you will see I am simply loading the UIView
once, then bringing it to the front layer... I would rather reload it entirely using remove from subview... but I couldn't get that to work..
Any one of the UIViews
can be loaded at one time which is what is causing me issue.
#pragma mark - Picker Delegates
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// ReloadView
if (row == 0) {
if (my1View == nil ) {
[self DrawView1];
}
[self.view bringSubviewToFront:my1View];
} else if (row == 1) {
if (my2View == nil ) {
[self DrawView2];
}
[self.view bringSubviewToFront:my2View];
}else if (row == 2) {
if (my3View == nil ) {
[self DrawView3];
}
[self.view bringSubviewToFront:my3View];
}else if (row == 3) {
if (my4View == nil ) {
[self DrawView4];
}
[self.view bringSubviewToFront:my4View];
}else if (row == 4) {
if (my5View == nil ) {
[self DrawView5];
}
[self.view bringSubviewToFront:my5View];
}else if (row == 5) {
if (my6View == nil ) {
[self DrawView6];
}
[self.view bringSubviewToFront:my6View];
}else if (row == 6) {
if (my7View == nil ) {
[self DrawView7];
}
[self.view bringSubviewToFront:my7View];
}else if (row == 7) {
if (my8View == nil ) {
[self DrawView8];
}
[self.view bringSubviewToFront:my8View];
}
}
The only other issue is that sometimes it will get stuck on one view when no matter what I pick nothing will load over it.