0

How can i display a button above a QTCaptureView? I have tried to put a button above the QTCaptureView on IB but when i run it, after the QTCaptureView starts showing the iSight camera image, the button hides behind the QTCaptureView...

Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76

2 Answers2

2

Try to set setWantsLayer:YES in IB to both QTCaptureView and NSButton. Not layer based views don't support overlapping.

Then after the xib is loaded the order may be not correct, so do in awakeFromNib:

- (void)awakeFromNib
{
  [self addsubview:qtView]
  [self addsubview:button]
}

I am not sure if it will help, but it should help. I had answer a similar question here

Community
  • 1
  • 1
Remizorrr
  • 2,322
  • 1
  • 17
  • 25
0

Like Davyd said, NSButton has nothing to do with CALayer How do you try to change the frame of the QTCaptureView? Please post code

IluTov
  • 6,807
  • 6
  • 41
  • 103
  • just by doing the `setFrame:` – Pedro Vieira Oct 11 '12 at 19:41
  • But what does that have to do with the NSButton? Please provide some code, I don't get what you want to do. Or at least tell me, when do you want to change the frame of the QTCaptureView, and what should happen, and what has the button to do with it – IluTov Oct 11 '12 at 19:50
  • mainly i want to display a button above the QTCaptureView. If you put 1 button on IB, above the QTCaptureView, and run it, after appearing the iSight feedback on the QTCaptureView, the button will hide behind the QT. I searched around for a way to fix it and i found that setting `setWantsLayer:YES` on the `contentView` of the Window that contains the QT, the button can now be seen above the QT and it doesn't hide anymore. But i also want to change it's(QT) frame later but it's not working when i try to use `NSMakeRect(0, 0, 541, 343)`. I think it's a problem with the `setWantsLayer:YES` – Pedro Vieira Oct 11 '12 at 19:56
  • if you know any other way of forcing the button to be above the QT all time tell me. – Pedro Vieira Oct 11 '12 at 19:56
  • why do you even setWantsLayers:YES ? – IluTov Oct 11 '12 at 20:04
  • as i said, i searched around i found out that setting `setWantsLayer:YES` would allow the button to be always above the QT. – Pedro Vieira Oct 11 '12 at 20:08
  • that has nothing to do with this, you use setWantsLayers if you are working with CALayers. Post the IBAction that is being triggered from the button. – IluTov Oct 11 '12 at 20:13
  • okay, so how can i force the button to be always above the QT? it's just this: `[[_outputView animator] setFrame:NSMakeRect(0, 0, 541, 343)];` – Pedro Vieira Oct 11 '12 at 20:16