Set QuickLook window size when previewing with QLPreviewingController.preparePreviewOfFile - swift

I am writing a QuickLook plugin for macOS and everything works, except that I can't set programmatically the window size of the preview.
It starts with 800x600, no matter what I do in the XIB and/or in the code, before and/or after the call to the completionHandler of preparePreviewOfFile.
Other file types, handled by the default plugin, adapts the preview window size to the content of the file. I would like to do just that.
The preview window is resizable by the user and, once resized, keeps the new size when I select another file in the Finder, to go back to 800x600 if I close it and reopen it on a file handled by my plugin.
What am I missing?

QLPreviewingController should set its preferredContentSize so that the window can be sized accordingly.
https://developer.apple.com/documentation/appkit/nsviewcontroller/1434409-preferredcontentsize

The accepted answer, setting preferredContentSize, seems to break the autoresizing of all subviews in macOS Catalina. After setting it, the content will no longer track the preview window size when the user resizes it manually or enters fullscreen.
See my question here.
So I'd like to add the following to the answer: There is no known way to do this on macOS Catalina without breaking autoresizing, but it works fine on macOS Big Sur. The preferredContentSize line should be wrapped in a #available(macOS 11, *) guard.

Related

How to make SwiftUI default to preview on the right side as portrait?

I'm on Catalina version 10.15, so this and this do not answer my question.
In the following image you will see the preview is underneath my code, I want it side by side.
(What I want) Such as in the following view:
One solution is simply to widen the Xcode Window and the preview will jump to be side by side.

macOS 11: Changing a NSSplitViewItem's NSTitlebarSeparatorStyle does not update immediately

If you change the titlebarSeparatorStyle property of a NSSplitViewItem, the window does not update immediately. You have to set the focus to another app first for the window to update. However the window isn’t update correctly either. For example the shadow never really gets applied. It works if you set the property in the storyboard. But if you want to change it programatically, it does not work as expected.
I would expect something like the Finder in Big Sur: If you display the content of a Finder window as symbols, there is no shadow or line below the toolbar. If you switch to another view (like column view) a line is being added and the toolbar becomes transparent.
I have added an example project to demonstrate the issue.
GitHub: SplitViewItem-titlebarSeperator
macOS 11.0.1 Beta (20B5012d)
Xcode Version 12.2 beta 3 (12B5035g)
https://openradar.appspot.com/radar?id=4949260923568128

Items Greyed Out in Xcode After Copying Between Storyboards

I have two storyboards and copied and pasted a view from one to the other. It still works normally however all of the items are greyed out like it is in the wrong size configuration. You can see my picture below showing the problem. I have the width and height set to exactly the same in both storyboards but Xcode is acting like it is in the wrong configuration to edit. (Yes, I've tried changing the configuration but all of them still present greyed out items).

My recent changes in NIB file is not displayed in ios simulator-closed

I've applied changes in interface builder for my app which has labels in it. I just changed the name and position of a label and in addition to that I changed the font of a text view in my app. When I started to run my app, the font remains the same as previous one and none of the labels are displayed in it.
Can anyone help it pls?
in Xcode try this: main menu:product:Clean
if not enough: main menu:Xcode:preferences: -> click over locations icon:
click over the little gray right arrow for derived data:
that will show you the finder folder "DerivedData": delete it.
one other thing to try: in simulator, delete your app.
quite your xcode and then again open your project . Clear your build then run your code.
You should also make sure, that the interfacebuilder file is linked to the target you are starting in simulator.
To do this, select your xib and open the File inspector. There you should see a dropdown named "Target Membership" where you can link the xib to the targets you want.
Also be sure to have the labels defined as IBOutlets in your header file and link them correctly in your xib. Easiest way to do this is using the Assistant Editor and drag the outlet to the header file.
I had the same problem - but only on the iPhone non-retina in the simulator. Cleaning the code did not help. Restarting and rebooting did not help. But removing the app from the simulator worked. Now changes to my UI show up next time I run.
To remove the app from the simulator I did it just like on a real phone. I select the app icon with the mouse and hold it down the mouse button for a few seconds. Then the icon displays a small delete icon that you can select (the app icons shakes too).

View Window Not Opening in Interface Builder

When I double click the XIB file in Xcode, Interface Builder typically launches a few different windows, one of which is the View window. For some reason, however, the View window isn't opening for one of my XIB files. If I open any of the other XIB files, however, the View window does open.
I'm not sure if there's a way to manually launch the View window (I looked through all of the menu items and couldn't find a way) or if I broke something in my XIB.
Update: I created a connection from the app delegate to a navigation controller, which seemed to break something. When I cleared that connection, the View window came back.
Are you referring to the window which allows you to view the objects in your XIB, or are you referring to the window which represents your XIB's primary view or window?
If you're referring to the main window which allows you to view the objects in your XIB, it sounds like you're most likely corrupted. I say this because that window represents the XIB file in whole, and if it isn't open, the file's probably not open. (Pro tip: Check the Window menu and see if the file name is listed in the file list. If it's not, it's not open. If it is, it is open and perhaps off-screen -- this has happened to me in the past when I've switched from a multi-monitor setup to just the laptop screen.)
If you're referring to a View or Window inside the XIB, double-click its icon from the XIB's main window.
I double clicked it and nothing happened. It just selected the window, wherever it may be and that's it. I tried Window -> Bring all to front and nothing.
Finally, I managed to recreate the problem. Usually I keep Xcode on my main screen and IB on my other monitor. If I close IB with my UIView there, disconnect the external monitor then start IB again, the said view disappears. Maybe it just slipped somebody's mind until now. I tried enabling expose, but it wasn't on that screen either. I couldn't bring the view back until I connected the external monitor again.
Hope that helps!
I had the exact same problem with opening a .xib file in Xcode and not being able to find the View window (that shows the application UI). Here was how I fixed the problem in my situation ... Open the .xib file, select the View object, go to the Tools menu and select Reveal in Workspace .. for me, this opened up the View window. Good Luck!
UPDATE - Or you can just double click the View object instead of going to the Tools menu - I think the first response suggested doing this, though that wasn't clear to me until after I posted this response.
I had the same problem. I fiddled with Deployment Target (changed from iPhone 4 to iPhone 3.2) and Development Target (changed from Interface Builder 3.2 to Interface Builder 3.0) for the xib file. It works wel now.
I solved this problem by playing around with my display settings. I had my iPad connected to my MacBook using Air Display. Disconnecting the iPad with Interface Builder windows left on it seems to leave those windows in "la-la land." Even re-connecting the device didn't seem to work. I had to open the Display preferences, choose "Detect Displays" and then choose "Mirror Displays". After that I de-selected "Mirror Displays" and closed out Interface Builder. Opening Interface Builder again brought the window back, but it was on my external display.
I think this is a bug in the sense that Apple should figure out a way to put all the windows back on the main screen once you detach the external one.