小编ori*_*ion的帖子

通过 SceneDelegate 进行 Catalyst 状态恢复不起作用

当通过停靠图标退出我的催化剂应用程序时(右键单击 -> 退出),我的 SceneDelegate 的stateRestorationActivity(for scene: UIScene)方法被调用,并且我返回一个非零的 NSUserActivity。

connectionOptions但是,当重新启动我的应用程序时,其中没有用户活动scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

对于其他人来说,这个功能是否正确?我是否需要以特定方式构建 UserActivity 才能在 Catalyst 中工作?在 iOS 上运行时可以正常运行。

uikit ios mac-catalyst

2
推荐指数
1
解决办法
527
查看次数

UIScrollView 子视图未扩展以填充宽度(自动布局)

我正在使用以下代码将视图约束到父 UIScrollView 的左右锚点。

尽管右锚和左锚被设置为 ScrollView 的左锚和右锚,但视图不会扩展以填充滚动视图。

注意:这张图片中的灰色背景是 UIScrollView 的背景,所以我知道它被正确地限制在它的父视图中。

代码:

self.wtfView.translatesAutoresizingMaskIntoConstraints = false
self.wtfView.backgroundColor = UIColor.orange
self.wtfView.topAnchor.constraint(equalTo: self.passwordField.bottomAnchor, constant: 40.0).isActive = true
self.wtfView.leftAnchor.constraint(equalTo: self.containerView.leftAnchor, constant: 40.0).isActive = true
self.wtfView.rightAnchor.constraint(equalTo: self.containerView.rightAnchor, constant: 40.0).isActive = true
self.wtfView.heightAnchor.constraint(equalToConstant: 50.0).isActive = true
self.wtfView.bottomAnchor.constraint(equalTo: self.containerView.bottomAnchor, constant: 40.0).isActive = true
Run Code Online (Sandbox Code Playgroud)

https://imgur.com/a/U88iW

编辑:以下代码工作正常,但我更喜欢使用左+右锚点技术来指定宽度,而不是在宽度约束下。那不应该吗?

self.wtfView.translatesAutoresizingMaskIntoConstraints = false
self.wtfView.backgroundColor = UIColor.orange
self.wtfView.topAnchor.constraint(equalTo: self.passwordField.bottomAnchor, constant: 40.0).isActive = true
self.wtfView.leftAnchor.constraint(equalTo: self.containerView.leftAnchor, constant: 40.0).isActive = true
self.wtfView.widthAnchor.constraint(equalTo: self.containerView.widthAnchor, constant: -80.0).isActive = true //THE DIFFERENT ONE
self.wtfView.heightAnchor.constraint(equalToConstant: 50.0).isActive = true
self.wtfView.bottomAnchor.constraint(equalTo: self.containerView.bottomAnchor, constant: …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios autolayout

1
推荐指数
1
解决办法
1520
查看次数

标签 统计

ios ×2

autolayout ×1

cocoa-touch ×1

mac-catalyst ×1

uikit ×1