I have been using an iPhone 4 for almost two weeks, and the only problem I have had with it was that every once in a while during the first few days — when I was in the middle of doing something else — I would suddenly get an error message on the screen saying “No SIM card installed.” The error was odd because it never happened when I was actively using the AT&T network, although I’m sure that my iPhone was communicating with AT&T towers in the background. One of the times that it happened, I snapped a picture of it so that I could post it here:

Whenever this happened, if I restarted my iPhone (hold down the button at the top for a few seconds, slide to power off, then press the button at the top to turn the iPhone on again), the iPhone would again see the AT&T network and not display the SIM card message. Nevertheless, it was annoying to have to restart my iPhone. At one point, I actually had to restart my brand new iPhone 4 twice during the same day.
I have seen all kinds of advice online regarding what to do in this situation. Some people suggested returning the iPhone to an AT&T store to get a new SIM card. Some people have suggested going to Settings –> General –> Reset –> Reset Network Settings. A third suggestion, and the one that I used, was to use a paperclip to eject the SIM tray on the side of the iPhone 4, take out the SIM card, put it back in again, and then replace the SIM tray. After doing that, I have now gone over a week since without seeing the error message again … long enough for me to decide to post here that this was a fix that worked for me, at least so far.
I was surprised to see that this is not an issue unique to the iPhone 4. People have been complaining online for years about seeing the same message on the iPhone 3GS and the iPhone 3G. I had just never heard about it before. And the problem isn’t even unique to the iPhone; there are lots of posts on the Internet with people making the same complaint about other phones that use SIM cards.
I have also seen a few posts that suggest that the problem is that there is dirt or a smudge on the SIM card. Thus, if the problem does happen to me again, I’ll try to gently wipe off the SIM card with a lint free cloth before I return it. Maybe there was a speck of dust on mine and the simple act of removing it and returning it knocked the dust off without me even noticing it. (And if there were any Whos down in Who-ville on that speck of dust, I apologize for not hearing you.) (Yes, perhaps I have been reading too many Dr. Seuss books to my kids.)
[UPDATE 8/5/10: After several weeks of everything being fine, the problem happened to me again last week IN THE MIDDLE OF A PHONE CALL. The call dropped, and I thought that maybe I just lost a 3G signal — something that doesn’t happen to me very often, but at the time I was in another city and wasn’t paying attention to the strength of the 3G signal in that area. But then I looked at the iPhone and saw the dreaded No SIM message. Arggh! So on Friday, July 30, I visited my local AT&T store, and the helpful salesperson said that the best fix is to replace the SIM card, which he did quickly. So far I’ve been using this new SIM card for about a week without any problems, but I’m keeping an eye on this. I’ll keep you posted on my experiences.]
[UPDATE 8/23/10: See this post.]
Hopefully this problem will never happen to any of you, but if it does, now you know some possible solutions.