There is no hard rule that a strip search cannot be performed by a different-gendered officer. The hard rule is that the search must be reasonable (as required by the 4th Amendment) , which means that there have to be sufficient reasons for the search. Depending on the circumstances, a search of a male by a female, or in view of a female, could be reasonable – and in other circumstances it could be unreasonable. As the court in Cookish v. Powell, 945 F. 2d 441 said,
In each case it requires a balancing of the need for the particular
search against the invasion of personal rights that the search
entails. Courts must consider the scope of the particular intrusion,
the manner in which it is conducted, the justification for initiating
it, and the place in which it is conducted
There are trends in the law which speak in favor of inmates right to privacy from cross-gender strip searches. Byrd v. Maricopa County Board of Supervisors is a recent decision where given the circumstances, a cross-gender search was found to be unreasonable. Cookish v. Powell is one where it wasn't unreasonable. This resource file assembles numerous court rulings, classifying them for judicial circuit, gender of staff vs. gender of inmate, sorting according to who prevails. The "rule" would be that the more intrusive the staff conduct is, the less reasonable the search is: but the more of an emergency there is, the more reasonable the search is.