I’ve built a view with IB, and included a UIButton in the view to deal with ‘background taps’ (placed behind all other items in the view). Originally, I had it size for the whole screen, color set to transparent, and hooked up to the ‘backgroundTap’ method in my controller.
Crazy thing is that is seemed like 1/2 times (exactly) I’d load the app in the Simulator, that UIbutton didn’t appear. So I colored the button green and ran the app, and lo and behold, it only appears half of the time (exactly half). Meaning:
- build app – it doesn’t show up
- close app
- build app – it shows
- close app
- build app – doesn’t show up
- close app
- build app – it shows
- … and so on
I tried resetting the info on the Simulator: Build – doesn’t show, close, build – does show. Each time after resetting the Sim, I build – button doesn’t show.
Considering that it happens exactly 1/2 times, figure it must have something to do with loading information…ANY THOUGHTS? I’m a newb, so this is pretty perplexing to me.
Thanks in advance for any help/thoughts!
Best,
Jared
One question to start.. Does the button exist every time and only visible half the time? Add an IBOutlet to the button and in your viewDidLoad print out the frame of the button. I’m wondering if the button IS there all the time, but perhaps it is getting pushed behind something else.
Definitely need to clean your workspace…
Stop the simulator (but don’t close it)
Build Clean.
Swap to the simulator and from the menu choose Reset Content and Settings.
Then try to rebuild and run and see if it freaking out still.
If so, rename that xib to something else and create a new xib exactly like it. Sometimes IB puts a xib into a weird state and you get ghosts in the machine like this.
If that doesn’t work, then start removing things from the xib and restarting until you find the culprit. Let us know how it goes!