Whatever caused it, the hard reset was the right thing to do. If there's been a lot of activity, such as installing or deleting apps, a hard reset gives the device a chance to organize all the changes.
Also, if there are multiple wireless networks available, make sure it's connected to the right one. It may be attempting to connect to another wireless network but doesn't have the password.
I'd DFU Restore and setup as new, if wifi issues persist, head to apple and get a replacement.
Don't hard reset your phone. That's foolish. It's the equivalent of pulling the power plug out of your iMac or mac mini while you're working on it.
Power it down normally by holding the sleep/wake button for 4 seconds and sliding to power off. Don't listen to these people who tell you hard reset your phone every day. They don't know what they're talking about and you'll end up causing far more problems than good.