I'm working on my first iPhone application and have stumbled upon an unknown bug in my code. The code works perfectly fine, but the problem lies when I tap a custom UIButton I've made and when it loads the next view. I have a desired buttonPressed IBAction that is called to handle what information loads on the next view controller, but the order of the function calls is wrong. I have 5 different buttonPressed functions and 3 out of the 5 are working correctly. Note I implemented them the same exact way through Storyboard and even tried re-making the non-working ones. I'd post code but the code is basic if/else statements. I'm just not sure why 3 out of the 5 ways would work and the other 2 wouldn't. Any help would be GREATLY appreciated.
**This is the desired order for the working 3:
viewDidLoad -> Loads main screen (initial view controller AKA ROOT, On main screen, you have 5 UIButtons to choose a category, tap a button to load to a new view controller)
categoryButtonPressed -> Sets counter (seques to new view controller)
viewDidLoad -> Loads Screen to narrow down search
(Now you have 10+ Custom Buttons to Tap on, each will be handled through a buttonPressed IBAction function, and once button is tapped and function is called, a new view is loaded)
buttonPressed -> Sets counter (seques to new view controller)
viewDidLoad -> Loads correct information
This is the order for the non-working 2:
viewDidLoad -> Loads main screen (initial view controller AKA ROOT) (On main screen, you have 5 UIButtons to choose a category, tap a button to load to a new view controller)
categoryButtonPressed -> Sets counter (seques to new view controller)
viewDidLoad -> Loads Screen to narrow down search (Now you have 10+ Custom Buttons to Tap on, each will be handled through a buttonPressed IBAction function, and once button is tapped and function is called, a new view is loaded)
viewDidLoad -> Loads blank information (blank screen)
buttonPressed -> Sets counter but is to late as the view already was loaded blank
Thoughts?**
Here is an example of the categoryButtonPressed:
-(IBAction)categoryButtonPressed:(id)sender
{
if([sender tag] == 1)
counter = 1;
else if([sender tag] == 2)
counter = 2;
.
.
.
}
NOTE: I have each custom button tagged for a specific item to be loaded. This function is just to set a counter so another function can load a specific file.