What makes you think it has been "hacked"? Unfortunately people immediately jump to this conclusion when anything bad happens on a device. If the phone is not jailbroken then it isn't hacked unless you are now world famous.
It is a very deliberate process. I guess if you left your phone lying around with no passcode and in the presence of people who would do that kind of thing it could happen.
Unauthorized modification of iOS has been a major source of instability, disruption of services, and other issues - http://support.apple.com/kb/HT3743 - unauthorized modifications to the iOS (this hacking process is often called "jailbreaking").
Again, knowing what is happening would allow us to help you in a more directed manner. It is almost certain that what you are experiencing is something you do not understand about how the phone is supposed to work, or is something like Safari pop-ups which is undesirable but a feature of the web today.
How do I know if it's been jail broken?
finding malware or spyware on iphone