problème bringSubviewToFront?
-
04-10-2019 - |
Question
HI, Je Parentview -> childviews multiples. quand j'utiliser la fonction [bringSubviewToFront: ChildView] dans parentview, cela fonctionne fine.but après avoir ajouté grandchildview à ChildView, quand je l'utilise [Auto bringSubviewToFront: grandchildview]? À parentview, cela n'a pas d'aide s'il vous plaît
La solution
La méthode -[UIView bringSubviewToFront:]
ne fonctionne que pour les enfants directs, pas petits-enfants. Rappelez-vous que la hiérarchie de la vue est un arbre, et, normalement, une vue ne connaît que son « parent » (ou superview) et ses « enfants » directs (ou) subviews. Vous devez faire quelque chose comme ceci:
// First, get the view embedding the grandchildview to front.
[self bringSubviewToFront:[grandchildview superview]];
// Now, inside that container view, get the "grandchildview" to front.
[[grandchildview superview] bringSubviewToFront:grandchildview];
Autres conseils
ma contribution avec la version rapide de la solution vérifiée
self.bringSubviewToFront(self.grandchildview.superview!)
self.grandchildview.superview!.bringSubviewToFront(self.grandchildview)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow