2016-05-09 13 views
1

私は画面をロックするアプリを持っているので、今は複数の画面で試してみる。私は第2画面のロックを解除することを知らない。ここ は、私は2番目の画面のロックを解除する方法である:第2画面のロックを解除する目的c

if([[NSScreen screens] count] > 1){ 
    // Draw a new window to fill the screen 
    NSScreen *screen; 
    NSRect screenRect = CGRectMake(0, 0, screen.frame.size.width , screen.frame.size.height); 

    NSWindow *secondaryMonitorWindow = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:screen]; 


    [secondaryMonitorWindow.contentView exitFullScreenModeWithOptions:nil]; 


} 

誰かが私を助けることができる場合、私は成功し、最初の画面ではなく、第二のロックを解除...

答えて

0

誰かが私は次のコードでそれを固定必要がある場合:

.M

[windowArray insertObject:self.window atIndex:0]; 

     //if we have many screens 
     NSRect screenRect; 
     NSArray *screenArray = [NSScreen screens]; 
     for (NSInteger index = 1; index < [screenArray count]; index++) 

     { 

      NSScreen *screen = [screenArray objectAtIndex: index]; 

      screenRect = CGRectMake(0, 0, screen.frame.size.width , screen.frame.size.height); 
      NSWindow *window = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:screen]; 

      [window.contentView setWantsLayer:YES]; 
      window.contentView.layer.backgroundColor = [NSColor blackColor].CGColor; 
      [window.contentView enterFullScreenMode:[[NSScreen screens] objectAtIndex:index] withOptions:nil]; 


      [windowArray addObject:window]; 

     } 

の.hに追加することを忘れないでください。
NSMutableArray *windowArray; 

そしてexitFullScreenへ:

for(NSInteger index = 1; index < [windowArray count]; index ++){ 

      if([[windowArray objectAtIndex:index]contentView].inFullScreenMode){ 

       [[[windowArray objectAtIndex:index]contentView] exitFullScreenModeWithOptions:nil]; 

      } 
     } 
関連する問題