R
R
Rou19972016-05-12 19:55:06
Cocoa
Rou1997, 2016-05-12 19:55:06

Cocoa on OS X in Xcode: why, if a WebView is added to the window, then at startup it will become empty, without any controls at all?

Created a project. Xcode, Cocoa, Swift (I don't think PL matters)
Dropped Button and Label.
Launched. Button and inscription in place.
Dropped WebView.
Launched. Empty - no button, no label, no WebView. I waited a little, "sipped" the window back and forth (suddenly there were problems with redrawing). Still empty.
Removed WebView.
Launched. The button and the inscription are back in place.
What could it be?
I worked with different "engines" of browsers, on different OS, platforms, and I have never seen anything like it. And Google also did not meet.
From my experience with WinForms, I would assume that by default the WebView fills the entire window and closes the controls.
But first, I tried Hidden and nothing changed.
Secondly, in Interface Builder, you can see that the WebView has "fixed" coordinates, and does not fill the entire container.
Thirdly, how could Apple's vaunted designers even admit that the design of the window in Interface Builder is so different from its appearance at startup, and this is in a Hello World application? Is this what I should want to lick? :) And if I lick, the WebView will appear? Is it their redrawing mechanism that works like that? Or is it something to do with security (surfing through a WebView), on the same principle as fingerprint scanning?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rou1997, 2016-05-18
@Rou1997

WebKit.framework should have been included.

A
Alexander Semchenko, 2016-05-12
@0xcffaedfe

Fourth, I advise you to smoke a book. For they say what and how to do, but what you thought to yourself there and how you would like it to be, few people care.

S
Shannon, 2016-05-14
@Shannon

In general, the advice is correct, though there is a problem, it’s easy to run into tutorials that teach you to immediately disable Auto Layout and manually set all the indents, which is completely unnecessary, since Interface Builder copes with this task itself
In a nutshell:
After all the necessary forms, buttons, etc. you need to click:
Resolve_Auto_Layout_Popup_2x.pngAll Views in View Controller -> Add Missing Constraints and / or arrange / correct them manually if the automatic method did not suit you
More:
https://developer.apple.com/library/ios/documentat...
Running (to see the result of the arrangement of elements), by the way, is also not necessary, the preview is done like this:
More:
https://developer.apple.com/library/ios/recipes/xc...
In general, poke around in this official section of Interface Builder , there are a lot of pictures that immediately explain what and how it works, the most common questions are sorted out there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question