This is only an intermittent problem but it is very annoying. Now and again I simply cannot get my iPhone 4 or new iPad to connect to my Apple TV either streaming media or by mirroring directly. I know only the new iPad is compatible for mirroring, but it it is very frustrating when it simply won't connect at all. And it's not as if my Apple TV isn't discoverable because the AirPlay icon always shows up. Anyone else experiencing this glitch? Please sort it out Apple!!
Intermittent problems are often a result of interference. Interference can be caused by other networks in the neighbourhood or from household electrical items.
You can download and install iStumbler (NetStumbler for windows users) to help you see which channels are used by neighbouring networks so that you can avoid them, but iStumbler will not see household items.
Refer to your router manual for instructions on changing your wifi channel or adjusting your multicast rate.
There are other types of problems that can affect networks, but this is by far the most common, hence worth mentioning first.