Comment faire pivoter UIView avec plein de contenu. Je rencontre un problème dans la rotation des UIViews. Quelqu'un peut m'aider??? s'il vous plaît donnez-moi un peu comme avec l'exemple étape par étape.Ipad/Iphone - Rotation dans UIView avec des images et tout
Répondre
Il est assez facile:
myUIView.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
qui fera tourner le tout 90 degrés vers la droite, le contenu et tout. L'argument de CGAffineTransformMakeRotation est en radians ...
Merci beaucoup mais je reçois encore un problème dans la rotation de l'image, il ne s'affiche pas correctement la vue se déplace correctement. –
Merci Andy, cela m'a beaucoup aidé! – iwasrobbed
Je voudrais aussi mettre une couleur de fond noire sur votre fenêtre aussi juste pour être sûr. J'ai eu un problème avec les lignes blanches tout en tournant et en changeant l'arrière-plan de ma fenêtre au noir. – jjxtra
Hey merci beaucoup pour votre réponse. Les trucs qui sont liés à la rotation sont résolus mais j'ai encore quelques problèmes en mode paysage j'utilise ce code pour animer deux UIViews mais en mode paysage Une vue n'apparait pas je veux une solution idéale pour cela.
Code rotation que je suis actuellement en utilisant ...
- (void)viewDidLoad
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)didRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[notification object] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft)
{
CGRect contentRect = CGRectMake(0,0, 1024, 748);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(M_PI/2.0)];
}
else if (orientation == UIDeviceOrientationLandscapeRight)
{
CGRect contentRect = CGRectMake(0,0, 1024, 748);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(M_PI/-2.0)];
}
else if (orientation == UIDeviceOrientationPortraitUpsideDown)
{
CGRect contentRect = CGRectMake(0,0, 768, 1024);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(M_PI)];
}
else if (orientation == UIDeviceOrientationPortrait) {
CGRect contentRect = CGRectMake(0,0, 768, 1024);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(0.0)];
}
}
UIView code amination.
self.loginView.hidden=NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
self.AcTypeView.transform=CGAffineTransformMakeTranslation(0, 493);
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
self.loginView.transform=CGAffineTransformMakeTranslation(0, -700);
[UIView commitAnimations];
Thanks!!!!
De quel type de rotation parlez-vous? Changement d'orientation? – AppAspect
rotation lorsque nous faisons pivoter Iphone/Ipad Paysage & Portrait je reçois problème avec l'interface, il montre un comportement différent. Si l'utilisateur fait une rotation, la vue de l'ipad/iphone devrait changer selon la rotation. –