最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

macos - How is this frame size computed for a TextView - Stack Overflow

programmeradmin10浏览0评论

I've got the following xib: (minimal example stripped from a larger UI)

<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
    <dependencies>
        <deployment identifier="macosx"/>
        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <objects>
        <customObject id="-2" userLabel="File's Owner" customClass="AboutWindowController"/>
        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
        <window id="5">
            <rect key="contentRect" x="641" y="589" width="538" height="337"/>
            <view key="contentView" id="123">
                <rect key="frame" x="1" y="1" width="523" height="188"/>
                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                <subviews>
                    <textView id="28">
                        <rect key="frame" x="0.0" y="0.0" width="523" height="188"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                    </textView>
                </subviews>
            </view>
        </window>
    </objects>
</document>

After compilation, the NSTextView gets NSFrameSize with the height of 337, but I'd like to understand why. Why is it getting the height from the contentRect and not the frame of the view? Is there a specific documentation link I can find about it?

I found it surprising since this structure:

        <window id="5">
            <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
            <rect key="contentRect" x="641" y="589" width="538" height="337"/>
            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
            <view key="contentView" id="6">
                <rect key="frame" x="0.0" y="0.0" width="538" height="337"/>
                <subviews>
                    <textField verticalHuggingPriority="750" preferredMaxLayoutWidth="0.0" id="13">
                        <rect key="frame" x="190" y="288" width="158" height="29"/>

does result in the height/width defined in the frame rect. (NSFrame is {190, 288}, {158, 29})

发布评论

评论列表(0)

  1. 暂无评论