If you notice that the autofocus of the iPhone camera does no longer focus, then this is not a defective camera hardware but a setting that is called "AE / AF lock". This message will appear to you on your iPhone in yellow at the top of the screen and means that the autofocus has been disabled.
To reverse this setting again, you must proceed as follows on your iPhone:
Type anywhere on the screen to turn off the Autofocus lock.
The autofocus lock on the iPhone was enabled as follows:
If you tap on the display long, the focus selection begins to pulsate two times and then the autofocus is locked on your iPhone camera
You know now why the autofocus of your iPhone's has stopped working properly and how to disable or enable the auto-lock for the autofocus.