2011-05-09 3 views

답변

12

과 같이 활동보기의 center 속성을 설정하십시오 :

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

이 장치 회전 알림을 등록 :

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

및 구현 didRotate:

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

화면을 회전해도 여전히 중앙에 위치합니까? 덕분에 – Tim

+0

아니, 당신은 그것이 등록 된대로 다시 센터로해야합니다. 기본적으로 회전 알림을 받으면 다시 가운데에 놓습니다. 그리고 Stack Overflow에 오신 것을 환영합니다. :) –

+0

어떻게 다시 센터로 만들 수 있습니까? 나는이 장소를 좋아하기 시작하고있다 – Tim

관련 문제