IPad external screen processing

Well, I think it's possible, I misunderstood the correct way to implement an external screen on the iPad, and it causes me a lot of headaches. Since this is a long post, I am trying to create and send a view to an external screen via VGA and remove the screen as soon as I finish this. I have problems with counting the account, so I can not get it to work.

I have a view controller that can be called up on the iPad at any time. When this view loads (it is remote, similar to the Keynote view), I check the external screen, then create a window and add the view to the secondary monitor.

in my ipadViewController.h<- view, which remains on the iPad

I have

@interface ipadViewController : UIViewController {

PresentationViewController *presentationView;
UIScreen *externalScreen;
UIWindow *externalWindow;
}

@property (nonatomic, retain) UIScreen *externalScreen;
@property (nonatomic, retain) UIWindow *externalWindow;
@property (nonatomic, retain) PresentationViewController *presentationView;
@end

(There is more, but it is an external screen).

ipadViewController.m:

@synthesize externalScreen;
@synthesize externalWindow;
@synthesize presentationView;

, :

( ) presentationViewController

- (void)viewDidLoad {
[super viewDidLoad];

[self getExternalScreen];
[self createPresentationAndSendToWindow];
}

, getExternalScreen::

if ([[UIScreen screens] count] > 1)
{
    for (UIScreen *currentScreen in [UIScreen screens])
    {
        if (currentScreen != [UIScreen mainScreen])
            self.externalScreen = [currentScreen autorelease];
    }

}

createPresentationAndSendToWindow::

if (self.presentationPath == nil) return;
PresentationViewController *viewController = [[PresentationViewController alloc] initWithNibName:@"CanvasPresentation" bundle:nil];


self.presentationView = viewController;
[viewController release];

if (self.externalWindow == nil)
{
    CGRect externalBounds = [self.externalScreen bounds];
    self.externalWindow = [[[UIWindow alloc] initWithFrame:externalBounds] autorelease];

    [self.externalWindow addSubview:self.presentationView.view];

    self.externalWindow.screen = self.externalScreen;

    [self.externalWindow makeKeyAndVisible];
}

in dealloc

[presentationView release];
[externalScreen release];
//[externalWindow release]; <- that would crash

, remoteViewController ( ), externalScreen count = 1, externalWindow count = 2.

, externalWindow release, , presentationView ( presentationView.

+3
2

:

for (UIScreen *currentScreen in [UIScreen screens])
{
    if (currentScreen != [UIScreen mainScreen])
        self.externalScreen = [currentScreen autorelease];
}

autorelease. , .

+1

self.externalWindow = [[[UIWindow alloc] initWithFrame:externalBounds] autorelease];

self.externalScreen = [currentScreen autorelease];

, .

0

Source: https://habr.com/ru/post/1754397/


All Articles