真的需要你的帮助!我已经完成了解决这个问题的所有可能的帖子,但似乎没有任何效果.
所以我使用.xib文件在ProfileFoldingCellView.swift中创建一个子视图,它完全有效,直到我尝试在同一个类中添加一个IBOutlet.这是代码:
import Foundation
import UIKit
class ProfileFoldingCellView: UIView {
@IBOutlet var mainLabel: UILabel!
public var cellIndex: Int = 0
init(index: Int) {
super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
cellIndex = index
print("Index: \(cellIndex)")
setupContentView()
}
func setupContentView() {
let contentView = UINib(nibName: "ProfileFoldingCellView", bundle: nil).instantiate(withOwner: nil, options: nil)[0] as! UIView
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
addSubview(contentView)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,标签IBOutlet的创建没有任何问题,并且没有其他过时或未使用的插件漫游.
我还确保将ProfileFoldingCellView.swift设置为文件所有者的类.
一切都运行良好,直到我连接插座!然后我收到这个错误:
相信我,我已经尝试了一切.我可能已经重新创建了一百万次,没有任何工作.任何帮助将不胜感激!
我们发送邀请时遇到问题GKGameCenterViewController.视图控制器打开就好了,但是当我们尝试向某人发送邀请时,它会立即失败.两个帐户都启用了游戏中心邀请,并通过GKGameViewController工作找到其他玩家.这是我们用来管理邀请的代码:
一旦GKLocalPlayer经过身份验证就调用此方法(从中调用身份验证GameViewController,此代码位于单独的Game Center管理类中):
internal func authenticationChanged() {
if GKLocalPlayer.localPlayer().authenticated && !authenticated {
print("Authentication changed: player authenticated")
authenticated = true
GKLocalPlayer.localPlayer().unregisterAllListeners()
GKLocalPlayer.localPlayer().registerListener(self)
} else {
print("Authentication changed: player not authenticated")
authenticated = false
GKLocalPlayer.localPlayer().unregisterAllListeners()
}
}
Run Code Online (Sandbox Code Playgroud)
这是收到邀请时应该调用的方法,尽管考虑到邀请一发送就失败就不会调用它.
public func player(player: GKPlayer, didAcceptInvite inviteToAccept: GKInvite) {
//presentingViewController.dismissViewControllerAnimated(false, completion: nil)
print("Accepted invite")
let mmvc = GKMatchmakerViewController(invite: inviteToAccept)!
mmvc.matchmakerDelegate = self
presentingViewController.presentViewController(mmvc, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
这两段代码都在符合GKMatchmakerViewControllerDelegate, GKGameCenterControllerDelegate, GKMatchDelegate, GKLocalPlayerListener委托和协议的同一个类中.