You are allowed to record an officer however, if you are being detained and they ask to search you, you can't have anything in your hands.