我创建了一个游戏SceneKit scene成UIViewController.
我实现了UITapGestureRecognizer这样的:
// TAP GESTURE
let tapGesture = UITapGestureRecognizer(target: self, action: "handleTap:")
sceneView.overlaySKScene?.view!.addGestureRecognizer(tapGesture)
Run Code Online (Sandbox Code Playgroud)
而handleTap功能:
func handleTap(sender: UIGestureRecognizer) {
if sender.state == UIGestureRecognizerState.Ended {
var touchLocation = sender.locationInView(sender.view)
touchLocation = self.view.convertPoint(touchLocation, toView: self.view)
let touchedNode = sceneView.overlaySKScene?.nodeAtPoint(touchLocation)
if touchedNode == myNode {
// DO SOMETHING
}
}
}
Run Code Online (Sandbox Code Playgroud)
想象一下,myNode这个位置是(x: 150.0, y: 150.0).问题在于它与'sy位置' touchPosition.y的y位置相反myNode.
如何反转触摸的y位置?
谢谢 !
有没有办法禁用移动过程中交换单元时发生的触觉反馈?
在我的应用程序中,我集成了GoogleMobileAds框架以添加一些横幅.问题是,每次启动项目时,都会收到错误消息No such module 'GoogleMobileAds'.我找到了一个解决方案,但它不是很有效:我删除了框架的引用,我在所有文件所在的文件夹中创建了一个文件夹,并将框架放入其中.每次启动Xcode时,我都需要删除框架的引用,并从我创建的Framework文件夹中再次添加框架,错误消息消失.
有人有解决方案吗?
谢谢 !
UPDATE
使用@ ethemsulan的答案找到解决方案:AdMob 7.3.1和Swift 2.0 - 找不到模块
有没有办法跟踪App Store下载源?例如,如果我在我的应用程序的Facebook页面上发布链接,我可以知道有多少人通过此链接下载了我的应用程序吗?
感谢您的回答.
我的卡由52张卡片组成,因此我array为他们创建了一张卡片,当用户点击屏幕时,会显示一张卡片.
我希望当卡被拉出时,将来再也无法拉出.我曾经removeAtIndex从拉出卡片中取出array.pullCard当用户在任何地方触摸屏幕时调用该函数:
// Cards
let card1 = (1, "AS", "RULE 1")
let card2 = (2, "2", "RULE 2")
let card3 = (3, "3", "RULE 3")
let card4 = (4, "4", "RULE 4")
let card5... (to 52)
// Array
var cards = [
card1,
card2,
card3,
card4,
card5... (to 52)
]
func pullCard() {
let randomCard = Int(arc4random_uniform(UInt32(cards.count)))
let cardsIndex = randomCard - 1
let card = cards[cardsIndex]
cards.removeAtIndex(cardsIndex)
}
Run Code Online (Sandbox Code Playgroud)
例如,游戏拉出卡32,因此将其从阵列中删除,如果游戏拉同一张卡,则因为卡被删除而崩溃.
我试图使用if语句:
if …Run Code Online (Sandbox Code Playgroud) 我花了很多时间寻找解决方案来限制UITableView.
这是我发现的一段代码:
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
if let selectedRows = tableView.indexPathsForSelectedRows {
if selectedRows.count == limit {
return nil
}
}
return indexPath
}
Run Code Online (Sandbox Code Playgroud)
问题是tableView.indexPathsForSelectedRows包含可见且来自任何部分的选定单元格。
像这样的属性是否tableView.selectedCellsForSection(section: 0)存在?
谢谢你的帮助 !
更新 1
这是一个包含多个选项的汽车示例
var selectedOptions = [IndexPath : Option]() // Option can be for example, the color of the car
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
let maxOptionForSection = car.options![indexPath.section]?.max
let numberOfSelectedOptions = selectedOptions.filter { …Run Code Online (Sandbox Code Playgroud)