UIScreen 对象定义了与硬件显示的相关属性,IOS设备有一个主屏幕,0个或是多个附加屏幕,用这个类来获取附加到设备屏幕的对象,每一个Screen对象都定义了矩形边界和一些其余有趣的属性brightness。ide
处理通知
spa
- (void)handleScreenConnectNotification:(NSNotification*)aNotification {
code
UIScreen* newScreen = [aNotification object];
对象
CGRect screenBounds = newScreen.bounds;
it
if (!_secondWindow) {
io
_secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
sed
_secondWindow.screen = newScreen;
object
// Set the initial UI for the window and show it.
date
[self.viewController displaySelectionInSecondaryWindow:_secondWindow];
硬件
[_secondWindow makeKeyAndVisible];
}
}
- (void)handleScreenDisconnectNotification:(NSNotification*)aNotification {
if (_secondWindow) {
// Hide and then delete the window.
_secondWindow.hidden = YES;
[_secondWindow release];
_secondWindow = nil;
// Update the main screen based on what is showing here.
[self.viewController displaySelectionOnMainScreen];
}
}