ios - Xcode:“GameView”类型的值没有成员“view”
问题描述
我尝试使用 Xcode 游乐场制作一些东西。当我尝试使用自动布局功能时,我收到一条错误消息,显示“GameView”类型的值没有成员“视图”
这是我的代码,还有更多,但我只添加了相关的部分。
import Foundation
import UIKit
import SpriteKit
public class GameView : UIView{
self.frame.size.width, height: self.frame.size.height))
override public init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: 0, width: 1500, height: 1000))
}
public override func addConstraints(_ constraints: [NSLayoutConstraint]) {
self.view.addConstraints([
NSLayoutConstraint(item: GameView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1.0, constant: 64),
NSLayoutConstraint(item: GameView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1.0, constant: 64),
NSLayoutConstraint(item: GameView, attribute: .centerX, relatedBy: .equal, toItem: self.view, attribute: .centerX, multiplier: 1.0, constant: 0),
NSLayoutConstraint(item: GameView, attribute: .centerY, relatedBy: .equal, toItem: self.view, attribute: .centerY, multiplier: 1.0, constant: 0),
])
}
}
提前致谢!
解决方案
好吧,它没有view
属性,我想您只想使用self
. 您可能从某种UIViewController
.
推荐阅读
- c++ - C++ 按需在线程中运行函数
- java - Spring PayloadValidatingInterceptor XsdSchemaCollection:由于 accessExternalSchema 属性设置的限制,不允许“zip”访问
- c# - 使用 IHttpClientFactory 设置默认请求标头
- java - 编辑 XML 并保存而不更改标签顺序
- java - 在 Java Swing 中更改按钮文本时遇到问题
- react-native - 使用 --host-rules 标志反应 Native ReCaptcha 收割机
- javascript - 尝试使用 ForEach() 更改数组中每个元素的样式
- vba - 在 Excel 中选择一个范围以粘贴来自 CATIA v5 VBA 的图片
- python - Chrome webdriver(Selenium)在获取特定元素后停止执行
- flutter - 如何选择多个图像并通过 RestAPI Flutter 上传