If you use the passcode feature with your iOS, at some time you may forget your code or someone may try to get into your device and disable the device temporarily. Before this happens, make sure you sync your device with iTunes or iCloud so that all will not be lost.
If you can’t remember your passcode, you may need to erase your device using iTunes, Find My Phone or recovery mode. Then, use a backup to put your data and settings back on your device.
If you have synced your device with iTunes, you can restore your device.
- Connect the device to the computer you normally sync with.
- Open iTunes. If iTunes asks you to enter the passcode, try another computer that you’ve synced with. Otherwise, follow the “Use recovery mode” section below.
- iTunes will automatically sync your device and create a backup. If it doesn’t, sync the device with iTunes.
- After the sync is complete, restore your device.
- When iOS Setup Assistant asks to set up your device, choose “Restore from iTunes backup.”
- Select your device in iTunes and choose the most recent backup.
Use Find My iPhone
If you enabled Find My iPhone, you can use it to erase your device.
- Go to icloud.com/#find to see if you enabled Find My iPhone.
- Click All Devices at the top of your browser window.
- Select your device and click “Erase [device]” to erase your device and its passcode.
- Use the Setup Assistant on your device to restore the most recent backup of your device.
Use recovery mode
Follow these steps if you never synced your device with iTunes, if you don’t have Find My iPhone set up, or if you can’t get to your own computer. You’ll need to put your device in recovery mode to erase the device and its passcode. Then you’ll restore your device.
- Disconnect all cables from your device.
- Turn off your device.
- Press and hold the Home button. While holding the Home button, connect your device to iTunes. If your device doesn’t turn on automatically, turn it on.
- Continue holding the Home button until you see the Connect to iTunes screen.
- iTunes will alert you that it has detected a device in recovery mode. Click OK, then restore the device.
This information comes directly from Apple’s knowledge base article.