As far as i can tell about your code description, the problem seems to occur when a subview (eg. UIAlertView) is created prior to its parent/super view. Something to do with the responder chain.
Try moving the view codes around to fix the problem or paste the relevant parts.