我试图让精灵永远上下移动,我尝试使用"if语句"检查位置是否......而不是再次向上移动.但它不起作用.我真的很感激一些帮助,谢谢!这是代码.
var Ground = SKSpriteNode()
var Ground2 = SKSpriteNode()
override func didMoveToView(view: SKView) {
Move()
}
func Move(){
let action = SKAction.moveToY(self.frame.height / 2 - 360, duration: 5.0)
Ground.runAction(SKAction.repeatActionForever(action))
let action2 = SKAction.moveToY(self.frame.height / 2 + 140, duration: 5.0)
Ground2.runAction(SKAction.repeatActionForever(action2))
}
Run Code Online (Sandbox Code Playgroud) 我想在上角用一个按钮制作一个tableview.我希望按钮再向表视图添加一行,以便您可以将图像添加到单元格或文本中.我在互联网上搜索但我没有找到答案.
这是源代码:
import UIKit
class TableViewController: UITableViewController {
var imageArray = ["1","2","3","4","5","6","7"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Reccept") as UITableViewCell!
let imageView = cell.viewWithTag(2) as! UIImageView!
imageView.image = UIImage(named: imageArray[indexPath.row])
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection …Run Code Online (Sandbox Code Playgroud)