NSTextView滚动视图切断文本

时间:2018-01-30 14:13:34

标签: xcode macos interface-builder nstextview

我已将“接口”构建器中的NSTextView放入我的故事板文件中。我将stringValue设置为从API端点返回的漂亮的JSON字符串。设置字符串后,包含NSTextView(Apple默认在IB中添加)的滚动视图无法获得正确的内容大小,因此您无法滚动查看整个内容。

selectedEndpoint.refreshHandler({ [weak self] (result) in

    guard let strongSelf = self else { return }

    switch result {
    case .success(let responseString):
        strongSelf.responses[strongSelf.selectedTab] = responseString
        OperationQueue.main.addOperation {
            strongSelf.responseTextView.string = responseString
            strongSelf.responseTextView.needsLayout = true
        }
        break
    case .failure(_):
        OperationQueue.main.addOperation {
            strongSelf.responseTextView.string = ""
            strongSelf.responseTextView.needsLayout = true
        }
        break
    }
})

参见附页截图:

App Image

Interface Builder

0 个答案:

没有答案