sud*_*-rf 12
尝试设置center活动视图的属性,如下所示:
activity.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2);
Run Code Online (Sandbox Code Playgroud)
在viewDidLoad,注册设备轮换的通知:
- (void)viewDidLoad {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:UIDeviceOrientationDidChangeNotification object:nil];
}
Run Code Online (Sandbox Code Playgroud)
并实施 didRotate:
-(void)didRotate:(NSNotification *)notification {
if (activity) {
activity.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3724 次 |
| 最近记录: |