Question

I have a problem with accessory views on NSSavePanel and NSOpenPanel.

Sometimes, (very often) when I open one of these panels the accessory view does not work (the view is shown but controls seem disabled).

I'm using this code to show the panel:

[openPanel beginSheetModalForWindow:appWindow completionHandler:openPanelHandler];

This only happens when app-sandbox is enabled.

After much testing I found out that what was happening was that the view was being misplaced (not attached to the panel).

When I open Mission Control and move the mouse pointer over the app windows I noticed that an "invisible" window hilighted and when select it I can take control over the accessory view (all controls work) but it appears detached from the open or save panel as shown on the screenshot.

Screenshot

I tried to create a new app just to test this behavior but was not able to reproduce it, so I suppose that has something to do with my app.

Any hint of what I may be doing wrong?

I don't want to code everything from scratch just to solve this issue.

Edit

Just a side note, when I close the window, just before the window close the accessory view flashes with the correct values for the controls. It appears that the application does not add the view in time for showing the panel.

Update 1

I subclassed the view that is used as accessory view and noticed that the

- (void)viewWillMoveToSuperview:(NSView *)newSuperview

is called, but

- (void)viewDidMoveToSuperview

never gets called even when the view is shown correctly, is this the normal behavior?

Update 2

I confirmed that - (void)viewDidMoveToSuperview should be called, on the test app both methods are called.

I also noticed a slight difference between my app and the test app. On my app the panel just slides down but on the test app the panel appears to "flip down" (don't know exactly how describe). The way the panel appears is irrelevant to me, I just noticed that it is not shown the same way.

Was it helpful?

Solution

After trying many things I concluded that the problem had to do with ARC (Automatic Reference Count) settings for the project.

In my case I had enabled ARC on target but not on project, after enabling ARC on project (and dealing with resulting errors and warnings) everything works perfectly now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top