Ios 接口生成器文件中的Xcode 9.3.1未知类
我一直在尝试为我的iOS游戏制作一个使用精灵套件制作的登录屏幕。我正在使用ramotion kit()进行同样的操作。我一直收到这个错误,接口生成器中的未知类,我已经在这个问题上纠缠了很久。以下是我的GameViewController类代码:Ios 接口生成器文件中的Xcode 9.3.1未知类,ios,swift,xcode,Ios,Swift,Xcode,我一直在尝试为我的iOS游戏制作一个使用精灵套件制作的登录屏幕。我正在使用ramotion kit()进行同样的操作。我一直收到这个错误,接口生成器中的未知类,我已经在这个问题上纠缠了很久。以下是我的GameViewController类代码: import UIKit import SpriteKit import PaperOnboarding protocol Controller { func levelCompleted() func levelFailed() }
import UIKit
import SpriteKit
import PaperOnboarding
protocol Controller {
func levelCompleted()
func levelFailed()
}
/* GameViewController is in charge of managing the game. This includes creating and
* changing levels, access to main menu, etc.
*/
var count = 0
class GameViewController: UIViewController, PaperOnboardingDataSource, PaperOnboardingDelegate
{
@IBOutlet var onboardingView: OnboardingView!
@IBOutlet var getStartedButton: UIButton!
@IBAction func playButtonPressed(_ sender: Any)
{
let controller = storyboard!.instantiateViewController(withIdentifier: "actualGame")
initialiseSKScene()
}
var currentLevel: Level? = nil
var config: GameConfiguration?
var skView: SKView?
override func viewDidLoad()
{
super.viewDidLoad()
onboardingView.dataSource = self
onboardingView.delegate = self
}
func initialiseSKScene()
{
let skView = initialiseSKView()
do
{
config = try GameConfiguration(file: "level_json_sample", size: skView.bounds.size)
}
catch let error
{
print("Level cannot be loaded!")
print(error)
}
let teethArray = config!.getTeethByLevel(id: 1)
let objectArray = config!.getObjectsByLevel(id: 1)
print(objectArray[0])
// Use the JSON file to open level 1
currentLevel = Level(size: skView.bounds.size, bgFile: "background2.png",
teethArray: teethArray, otherArray: objectArray, c: self as! Controller)
currentLevel?.scaleMode = SKSceneScaleMode.resizeFill
skView.presentScene(currentLevel)
}
func onboardingItemsCount() -> Int
{
return 3
}
func onboardingItem(at index: Int) -> OnboardingItemInfo
{
let onBoardItem1 = OnboardingItemInfo(informationImage: UIImage(named: "rocket")!,
title: "A Great Rocket Start",
description: "Caramels cheesecake bonbon bonbon topping. Candy halvah cotton candy chocolate bar cake. Fruitcake liquorice candy canes marshmallow topping powder.",
pageIcon: UIImage(named: "rocket")!,
color: UIColor(red: 217/255, green: 72/255, blue: 89/255, alpha: 1),
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont(name: "AvenirNext-Regular", size: 18)!)
let onBoardItem2 = OnboardingItemInfo(informationImage: UIImage(named: "brush")!,
title: "Design your Experience",
description: "Caramels cheesecake bonbon bonbon topping. Candy halvah cotton candy chocolate bar cake. Fruitcake liquorice candy canes marshmallow topping powder.",
pageIcon: UIImage(named: "brush")!,
color: UIColor(red: 106/255, green: 166/255, blue: 211/255, alpha: 1),
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont(name: "AvenirNext-Regular", size: 18)!)
let onBoardItem3 = OnboardingItemInfo(informationImage: UIImage(named: "notification")!,
title: "Stay Up To Date",
description: "Get notified of important updates.",
pageIcon: UIImage(named: "notification")!,
color: UIColor(red: 168/255, green: 200/255, blue: 78/255, alpha: 1),
titleColor: UIColor.white,
descriptionColor: UIColor.white,
titleFont: UIFont(name: "AvenirNext-Bold", size: 24)!,
descriptionFont: UIFont(name: "AvenirNext-Regular", size: 18)!)
return [onBoardItem1,onBoardItem2,onBoardItem3][index]
}
/* Initialises the SKView where we display the game */
private func initialiseSKView() -> SKView
{
let skView = self.view as! SKView
skView.showsFPS = true
skView.showsPhysics = true
skView.showsNodeCount = true
skView.ignoresSiblingOrder = true
skView.isMultipleTouchEnabled = false
return skView
}
/* This method is called by the currentLevel when it is completed */
func levelCompleted() {
// check if there exists a higher level than currentLevel.id
// change to next level or present winning screen
let reveal = SKTransition.flipHorizontal(withDuration: 0.5)
let gameOverScene = GameOverScene(size: skView!.bounds.size, won: false)
skView?.presentScene(gameOverScene, transition: reveal)
}
func onboardingConfigurationItem(_: OnboardingContentViewItem, index _: Int)
{
}
func onboardingWillTransitonToIndex(_ index: Int)
{
if index == 1
{
if self.getStartedButton.alpha == 1
{
UIView.animate(withDuration: 0.2, animations:
{
self.getStartedButton.alpha = 0
})
}
}
}
func onboardingDidTransitonToIndex(_ index: Int)
{
if index == 2
{
UIView.animate(withDuration: 0.4, animations:
{
self.getStartedButton.alpha = 1
})
}
}
/* This method is called by the currentLevel when it is failed */
func levelFailed() {
// present losing screen
let reveal = SKTransition.flipHorizontal(withDuration: 0.5)
let gameOverScene = GameOverScene(size: skView!.bounds.size, won: false)
skView?.presentScene(gameOverScene, transition: reveal)
}
}
我在interface builder错误中得到未知类,ViewDidLoad()中的这一行显示:
“线程1:致命错误:在展开可选值时意外发现nil”
我已经在interface builder中检查了我所有的插座和类,它们都是正确的!
非常感谢您的帮助 请再次尝试连接插座。未成功。现在我得到“无法将'UIView'(0x10c52bfd8)类型的值强制转换为'SKView'(0x10af21480)”,并在“let SKView=view as!SKView”处出现SIGABRT错误,这是initialiseSKView()函数的第一行。有什么想法吗?确保你的xib上有SKView。谢谢@TalCohen的评论。你能告诉我如何与代码相关吗?
onboardingView.dataSource = self