Tag: uiwindow

在rootViewController中使用第二个UIWindow时,会导致界面旋转变黑

(iOS 7.0.3,Xcode 5.0.1) 我的应用程序中有第二个UIWindow用于在状态栏上方显示自定义放大镜。 但是,一旦我设置了这个窗口的rootViewController(用于界面旋转和一些其他的东西),主界面在界面旋转animation过程中变黑。 要重现:创build单个视图的iOS应用程序,并将以下添加到主UIViewController。 // To @interface: @property (nonatomic, strong) UIWindow *secondWindow; // In viewDidLoad: self.secondWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.secondWindow.rootViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil]; self.secondWindow.hidden = NO; 任何帮助赞赏。

如何删除一个UIWindow?

我认为这很容易,因为[myWindow resignKeyWindow]和[self.window makeKeyAndVisible]但我猜不是…你们知道该怎么办? 谢谢 :)

应用程序委托必须实现窗口属性,如果它想要使用主要故事板文件

我以编程方式实现列表视图控制器。 当我尝试运行该项目时,出现错误: 2012-11-07 22:46:34.719 myTableViewControl[12021:c07] The app delegate must implement the window property if it wants to use a main storyboard file. 2012-11-07 22:46:34.722 myTableViewControl[12021:c07] -[AppDelegate setWindow:]: unrecognized selector sent to instance 0x7674e70 2012-11-07 22:46:34.723 myTableViewControl[12021:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate setWindow:]: unrecognized selector sent to instance 0x7674e70' *** First […]

设置UIWindow的rootViewController是做什么的?

将视图控制器分配给此属性(以编程方式或使用Interface Builder)将视图控制器的视图作为窗口的内容视图进行安装。 上面的引用来自UIWindow的参考。 我的问题是关于特定的阶段: “作为窗口的内容视图安装视图控制器的视图” 内容视图究竟是指什么? http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html

旋转后的UIView坐标交换,但UIWindow的不是?

使用Xcode 4.2.1 iPad iOS 5.0.1,创build一个新的“Single View”iPad项目。 在控制器中添加: – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } – (void) dumpView: (UIView *) view { CGRect frame = view.frame ; CGRect bounds = view.bounds ; CGPoint center = view.center ; NSLog(@"view [%@]:%d frame=%@ bounds=%@ center=%@" , NSStringFromClass(view.class) , [view hash] , NSStringFromCGRect(frame) , NSStringFromCGRect(bounds) , NSStringFromCGPoint(center)) ; } – (void) […]

iOS – 未收到UIEventTypeRemoteControl事件

我有这个在AppDelegate(didFinishLaunching): [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 我试图在相关的视图控制器中处理这些事件,但是这是有缺陷的(一些视图控制器会得到事件,而其他视图控制器不会,即使他们是第一响应者)。 我试过UIApplication的子类。 这没有用。 现在我正在尝试子类UIWindow并执行此操作(请参阅注释): – (void)sendEvent:(UIEvent *)event { if (event.type == UIEventTypeRemoteControl) { NSLog(@"I wish this happened"); //this never happens } else { NSLog(@"some other event"); //this does happen on any other interaction [super sendEvent:event]; } } – (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent { if (receivedEvent.type == UIEventTypeRemoteControl) { NSLog(@"got remote […]

将UIView原点转换为其Window坐标系

我想在窗口坐标系中获取scrollView的原点。 例如,目前,scollView的来源是(0,51)。 但在窗口坐标系中,它应该是51 + 44(导航栏高度)+20(状态栏高度)= 115。在窗口坐标系中,scrollView.frame.origin应该是(0,115)。 我尝试使用convertPoint:方法,但有时得到(0,51)或(0,0)。 请为此提供解决scheme。 谢谢

以编程方式在iOS中以状态栏捕捉完整屏幕截图

我正在使用此代码来捕获屏幕截图并将其保存到相册中。 -(void)TakeScreenshotAndSaveToPhotoAlbum { UIWindow *window = [UIApplication sharedApplication].keyWindow; if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(window.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(window.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); } 但问题是,每当屏幕截图保存,我看到iPhone的状态栏没有被捕获。 而是在底部出现一个空白区域。 像下面的图片一样: 我究竟做错了什么?

iOS – 在窗口中获取视图的位置?

我有一个UIView,它被点击后显示一个popup窗口。 popup窗口需要被添加到主UIWindow,以确保它在所有其他的顶部。 我想这个popup窗口的位置是相对于我的UIView,所以我需要知道我的UIView在窗口中的相对位置。 问题:当UIView不是直接在UIWindow中(它在我的viewController的视图内)时,如何才能在UIWindow中findUIView的位置?

具有UIWindowLevelStatusBar旋转问题的iOS 8/7 UIWindow

我试图添加UIWindow与UIWindowLevelStatusBar级别。 它在ipad完美的肖像模式工作,但旋转设备后,它搞砸了。 在iOS 7.x中,除了颠倒以外,所有的旋转都很好,而在iOS 8.x上,只有肖像模式很好,所有其他的方向都搞砸了。 任何想法如何解决? CGRect frame = [UIApplication sharedApplication].statusBarFrame; self.statusWindow = [[UIWindow alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, 20)]; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; CGRect frame = [UIApplication sharedApplication].statusBarFrame; CGAffineTransform test = [self transformForOrientation:orientation]; [self.statusWindow setWindowLevel:UIWindowLevelStatusBar]; [self.statusWindow setHidden:NO]; – (CGAffineTransform)transformForOrientation:(UIInterfaceOrientation)orientation { switch (orientation) { case UIInterfaceOrientationLandscapeLeft: return CGAffineTransformMakeRotation(-DEGREES_TO_RADIANS(90.0f)); case UIInterfaceOrientationLandscapeRight: return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90.0f)); case UIInterfaceOrientationPortraitUpsideDown: […]