关于macos:如何设置NSScrollView的内容大小? | 珊瑚贝

How to set the content size of NSScrollView?


我是 Mac OSX 编程的新手。我在 iOS 应用程序上创建了可以使用 contentSize 属性设置 UISCrollView 的内容大小的应用程序。但是我没有为 Mac Apps 找到这样的属性。如何完成以及如何在 Mac App 中启用滚动。我查看了 Stackoverflow 上的其他问题,但没有发现任何相关内容。
谢谢-

  • 你有什么发现吗?


NSScrollView 附加了 documentView。您可以通过更新 documentView 的框架来更改内容大小。

[scrollView.documentView setFrame: NSMakeRect(0,0,new_width, new_height) ];

  • CGRectMake 与 NSRect 不兼容,无法编译。
  • 它编译得很好。 NSRect 只是 CGRect 的 typedef。
  • 仅在编译为 64 位时。
  • 您可以改用 NSMakeRect
  • 注意:更新 documentView 的框架非常重要,而不是它的边界。我只是浪费了几天,因为我正在更改边界,这会产生与预期完全不同的结果。
  • 似乎在 Swift 中不起作用,因为 documentView 是一个常量,因此不能分配它的变量。


来源:https://www.codenong.com/9768995/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8694.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?