ios - iPhone Force Adjust External Screen Resolution -


the application in question must allow user select 1 available screen modes of selected display. example, external display may natively support 1920x1080 it's edid show supported resolutions of 1920x1200, 1280x720 , 1024x768.

by default, connected external display ios device appears favor highest supported resolution o external display. have allowed user select list of uiscreenmode.availablemodes change resolution. once mode selected , applied externalscreen.currentmode appear the new resolution being considered.

in testing, have assigned view external display red. after changing resolution from, example, 1920x1080 1024x768, red box displayed on monitor @ 4:3 aspect ratio. doing same 1280x720 keeps red box 16:9 fills screen same 1080.

however, red box contains 2 labels autolayout constraints. when resolution changes, x/y coordinates of labels stay same relative red box. should centered in red box, not seem re-layout when resolution changed. additionally, physical size of labels enlarges when resolution dropped, shows being affected in way resolution change.

so, how can subviews of red box (a uiview assigned externaldisplay) updated after changed uiscreenmode.currentmode?

below simplified version of going on:

var externalscreen:uiscreen! var externalwindow: uiwindow! var extview: myexternaldisplay?  func initializeexternalscreen(externalscreen:uiscreen) {     self.externalscreen = externalscreen      // create new window sized external screen's bounds     self.externalwindow = uiwindow(frame: self.externalscreen.bounds)      // assign screen object screen property of new window     self.externalwindow.screen = externalscreen      // load clock view     let clockview = self.storyboard?.instantiateviewcontrollerwithidentifier("externaldisplay") as! externaldisplay     clockview.view.frame = self.externalwindow.frame      // add view window     self.externalwindow.addsubview(clockview.view)      // create reference clockview     self.extview = clockview      // make window visible     self.externalwindow.makekeyandvisible() }  func applynewmode () {     let newmode = externalscreen.availablemodes[1] // 1024x768     externalscreen.currentmode = newmode } 

this called when screenmodedidchange notification received.

func handescreenmodedidchangenotification (notification:nsnotification) {         extview?.view.frame = externalwindow.frame         extview?.view.layoutsubviews() } 

update

adding following response screenmodedidchange notification seems - - solve issue. results inconsistent , not sure if ios 9 beta issue or not.

func handescreenmodedidchangenotification (notification:nsnotification) {     let screen = uiscreen.screens()[1]     initializeexternalscreen(screen) } 

update #2

while seems possible change resolution of external screen methods listed here, not change actual output resolution. example, if ios device connected monitor showing preferred edid of 1920x1080 device default resolution. changing resolution using previously-mentioned methods change resolution of presented image, output resolution stays 1920x1080. in essence, happening reduction in resolution of displayed content while actual output resolution remains unchanged.


Comments