Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法获取scrollview.contentInsetAdjustmentBehavior=。无法在Mac OS中工作_Ios_Swift_Macos_Scrollview - Fatal编程技术网

Ios 无法获取scrollview.contentInsetAdjustmentBehavior=。无法在Mac OS中工作

Ios 无法获取scrollview.contentInsetAdjustmentBehavior=。无法在Mac OS中工作,ios,swift,macos,scrollview,Ios,Swift,Macos,Scrollview,将iPad应用程序转换为Mac操作系统(在应用商店中工作多年)。将可滚动文本视图作为更大的视图控制器框架/布局的一部分。可滚动文本视图工作正常,但顶部有一个偏移(松开前2-3行)。使用:myScrollView.contentInsetAdjustmentBehavior=.never成功为iOS(iPhone和iPad)实现 苹果公司的文档表明,同样适用于Mac操作系统,但得到了补偿 可滚动myTextView是添加到视图控制器的第二个视图,该视图控制器嵌入在导航控制器中 viewDidLoa

将iPad应用程序转换为Mac操作系统(在应用商店中工作多年)。将可滚动文本视图作为更大的视图控制器框架/布局的一部分。可滚动文本视图工作正常,但顶部有一个偏移(松开前2-3行)。使用:myScrollView.contentInsetAdjustmentBehavior=.never成功为iOS(iPhone和iPad)实现

苹果公司的文档表明,同样适用于Mac操作系统,但得到了补偿

可滚动myTextView是添加到视图控制器的第二个视图,该视图控制器嵌入在导航控制器中

viewDidLoad中的相关代码:

#if targetEnvironment(macCatalyst)

  myScrollView.translatesAutoresizingMaskIntoConstraints = false
  myScrollView.contentInset = UIEdgeInsets.zero
  myScrollView.scrollIndicatorInsets = UIEdgeInsets.zero
  myScrollView.contentOffset = CGPoint( x: 0.0, y: 0.0)
  myScrollView.setContentOffset(CGPoint: x: 0.0, y: 0.0)
  myScrollView.frame.size.width = UIScreen.main.bounds.width
  myScrollView.contentSize = CGSize(width: myScrollView.frame.width, height: 2000)
  myScrollView.isScrollEnabled = true
  myScrollView.clipsToBounds = true
  myScrollView.contentInsetAdjustmentBehavior = .never

  view.addSubview(myScrollView)

  myScrollView.topAnchor.constraint(equalTo: horizontalstckView2.bottomAnchor, constant: 20).isActive = true
添加了更多查看项目

#endif
以上代码适用于iPad(无插图)。感谢您对遗漏内容的帮助