問題タブ [nsstackview]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
macos - Cocoa autolayout を使用してビューを非表示および表示する
Autolayout を使用してボタンがクリックされたかどうかに基づいて、次の図のビュー #1 を非表示にして表示しようとしています。誰でもこれを行う方法を知っていますか?
ビュー #2 に 2 つの NSLayoutConstraints を設定しようとしました。1 つはビュー #1 とビュー #2 のスーパービューの上部に関連付けられ、もう 1 つはビュー #1 の下部に関連付けられています。ビュー#1を非表示にするNSLayoutConstraintsですが、それは何もしていないようです。
アドバイスをいただければ幸いです。私は主に IB でこれを行おうとしていますが、プログラムによる解決策も歓迎します。
参照用の写真:
ios - なぜios7で私のstackViewControllerがこの白い線を入れたのですか?
左下にこの空白があるのはなぜですか? ios6 のコンパイル済みバージョンにはありませんでした。削除する方法がわかりません。私のnibファイルにはありません(トップレベルのビューはご覧のとおり大きく(画像から20ピクセル残っています)、コントローラー側にはビューの寸法の痕跡はありません.
編集:私はすでにコードに C_X ソリューションを配置しようとしました:
しかし、うまくいきません。何か案は?
編集: 問題解決: PSStackedView ( https://github.com/steipete/PSStackedView/ ) というプラグインを使用しています。iOS7 で正しく使用するに は、アプリケーションではなく境界でviewRectを変更する必要があります。
}
objective-c - NSStackView は最新のカスタム ビューのみを表示します
カスタム ビュー コントローラー クラスがあります。複数のカスタム ビュー コントローラーをインスタンス化し、それらのビューを NSStackView に追加したいと考えています。ボタンをクリックして、新しいビューをスタック ビューに追加します。ボタンは次のメソッドを呼び出します。
ただし、新しいビューが追加さstackView.spacing
れると、前のビューがあった場所の下に追加されますが、その前のビューは表示されなくなりますが、呼び出したときに証明されるように、下の重力のビューとしてまだリストされています
sを追加しようとしてもこの問題は発生しないNSButton
ので、カスタム ビューと関係がありますが、何が原因かわかりません。
助けてください。ありがとう!
objective-c - NSStackView がビューを適切にレイアウトしない
の実験を始めたばかりでNSStackView
、解決できない非常に興味深い問題があります。Apple の Web サイトの自動レイアウト ガイドとドキュメントを精査しましたが、NSStackView
何も見つからないようです。
私の問題は、nib ファイルからロードされる2 つの同一NSScrollView
のオブジェクト (それぞれに が埋め込まれている) があることです。NSTextView
これらのビューをスタック ビューに追加すると、最初に追加されたビューが使用可能なスペースの 100% を占有し、2 番目のビューは使用可能な水平スペースをすべて占有しながら、高さ 2 ピクセルで下部まで完全に折りたたまれます。実際、これは最初のビューだけがウィンドウ内にあるように見えます。現在の外観は次のとおりです。
この例では、背景色のためにほとんど見ることができませんが、スクロール ビューはウィンドウの下部から数ピクセル上で終了します。これは、ビュー階層インスペクターからのより良いビューです。ここでは、この 2 ピクセルの高さのビューを選択しています (拡大するにはここをクリックしてください)。
関連するセットアップコードは次のとおりです。
私が理解していることから、固有のコンテンツ サイズにより、ビューがこれほど小さく縮小されることはありません。私はあまり詳しくないNSStackView
ので、助けていただければ幸いです。
cocoa - NSStackView places NSViews on the baseline
Having reviewed most of Apple's (paucity) of documentation regarding NSStackView, plus the wise words of the greater Internet, including the collective wisdom of Stackoverflow, a problem remains.
Any NSView I add programmatically to my (IB instantiated) NSStackView, visually locate themselves to the bottom of their respective gravity area. Hence they overlay each other and don't behave like an expected "stack" of views with appropriate spacing.
Each of the gravity areas seem somehow compressed and unable to accommodate any more views. The more I apply NSStackView.addView to a gravity area the slimmer the existing views become.
I would expect NSStackView to naturally expand to accommodate the .size of the embedded views.
Any wise counsel is most appreciated ...
---more details—</p>
I place the StackView into the main window using interface builder. I can then add other views into areas of the stack in interface builder, such as buttons. These stack and layout as expected in IB and when running.
However, when I add or insert any view programmatically to any gravity area their bottom edge is positioned vertically down to the bottom edge of the StackView. This layout behaviour is the same for a vertical or horizontal stack.
Consequently, if I add more than one view programmatically they are sized OK and display but overlap. I am using 'NSBox' objects as views (for now) and they are sized using '.sizeToFit()'. I can see that their '.bounds.height' and 'width' are non zero.
I'm not sure how to set or log the intrinsic content size. That might be the next thing to try.
—no luck—
So, I have now worked rigorously through all permutations of: compression, hugging, (non-zero) intrinsic sizing, constraints, no constraints and various types of NSViews, but ... if I '.addView(...)' or '.insertView(...)' more than once, in any 'NSStackView' gravity area, the subsequent views overlay the previous ones and position themselves on the particular baseline. This is the edge closest to the floor of my office, regardless of the stack orientation.
Any 'NSStackView' and AutoLayout help, either emotional or technical, is most appreciated.
objective-c - プログラムで NSStackView にビューを追加した後、ビューが正しく表示されない
いくつかのビュー (この例では NSTextField) を NSStackView に追加しようとしています:
NSStackView インスタンスを XIB ファイルに追加し、ウィジェットとしてアウトレットにDocumentにリンクしました。...didLoadNibで私はこれをやっています:
TextField は StackView に配置されますが、同じ位置に配置されます。つまり、2 番目のフィールドが最初に完全に重なります。[スペース+タブ]で最初に選択できます。
コンソール出力は次のとおりです。
XIB と結果のスクリーンショット:
StackView に追加される制約はありません。StackView は垂直にする必要があります。スタックビューに動的な量のテキストフィールドが追加されます。