iPad VGA Connector - Mirror screen in own Applicat

2020-05-11 20:15发布

问题:

Is it possible to mirror the Screen over the VGA Connector? Can't find anything about this.

回答1:

I was looking for the same thing you are. Last weekend I wrote a small UIApplication category to add mirroring support. I published to code on Google Code.

http://code.google.com/p/iphoneos-screen-mirroring/

To use it, you simply have to set it up in your application delegate's app did finish lauching. Like so:

[[UIApplication sharedApplication] setupScreenMirroringOfMainWindow:mainWindow framesPerSecond:20];

I only had one chance to try it out last weekend on a big screen TV with the Apple AV output cables. The performance is not stellar, thus I would not recommend using a frame rate higher than 30 fps...



回答2:

I think it worth adding that the QuartzCore framework is mandatory, or you'll have 4 errors at compile time.

Undefined symbols:
  "_CATransform3DMakeRotation", referenced from:
      -[UIApplication(ScreenMirroring) updateMirroredWindowTransformForInterfaceOrientation:] in UIApplication+ScreenMirroring.o
      -[UIApplication(ScreenMirroring) updateMirroredWindowTransformForInterfaceOrientation:] in UIApplication+ScreenMirroring.o
      -[UIApplication(ScreenMirroring) updateMirroredWindowTransformForInterfaceOrientation:] in UIApplication+ScreenMirroring.o
  "_kCAGravityResizeAspect", referenced from:
      _kCAGravityResizeAspect$non_lazy_ptr in UIApplication+ScreenMirroring.o
     (maybe you meant: _kCAGravityResizeAspect$non_lazy_ptr)
  "_OBJC_CLASS_$_CADisplayLink", referenced from:
      objc-class-ref-to-CADisplayLink in UIApplication+ScreenMirroring.o
  "_CATransform3DIdentity", referenced from:
      _CATransform3DIdentity$non_lazy_ptr in UIApplication+ScreenMirroring.o
     (maybe you meant: _CATransform3DIdentity$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status


回答3:

Each UIWindow object (basically the top level view) is assigned a screen (UIScreen) and you can of course set the screen you want. Therefore moving the main content to a second screen is easy, but mirroring is hard. (If you don't want a lecture on why it's ugly skip until the next paragraph) I believe this is apple's intention, both because drawing the same thing twice, one with a MUCH higher resolution, and because the experience of watching the interface before entering whatever presentation mode is rather subpar in comparison to seeing nothing until the video is playing, keynote presentation has started, etc. This is something you obviously want to consider on a case by case basis, but nonetheless mirroring is a Bad Idea.

UIWindow inherits from UIView, so although I don't have much personal experience with this exact thing, you should still be able to get it to draw to a bitmap context of some kind, and then use two different UIWindows each with only an image view on a them pushing the actual pixels to their respective screens. This is considerably easier if you only want to mirror one specific custom view (and not including it's subviews) because you can have that view on the device screen, (to capture any input) and then design it in a way that you have a method to call to draw it in whatever context it's in (some drawRects might work fine as is) and the call that from a super special awesome custom subview on the other screen, which would implement drawRect to just call the method on the actual view.

Hope this helps, sorry I ranted a bit :(



标签: ipad vga