2011-05-09 15 views

Respuesta

12

intente configurar la propiedad center de la vista de la actividad, así:

activity.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2); 

En viewDidLoad, registrar para notificaciones de la rotación del dispositivo:

- (void)viewDidLoad { 
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(didRotate:) 
     name:UIDeviceOrientationDidChangeNotification object:nil]; 
} 

e implementar didRotate:

-(void)didRotate:(NSNotification *)notification { 
    if (activity) { 
    activity.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2); 
    } 
} 
+0

¿Seguirá estando centrado cuando gire la pantalla? gracias – Tim

+0

No, tendrás que volver a centrarlo tan pronto como registre que está activado. Así que, básicamente, simplemente centre nuevamente cuando reciba la notificación de rotación. Y bienvenidos a Stack Overflow. :) –

+0

¿cómo y dónde lo hago volver a centrar? Me está empezando a gustar este lugar – Tim

Cuestiones relacionadas