简体   繁体   English

Xcode 源文件中的编辑器 PlaceHolder

[英]Xcode Editor PlaceHolder in source file

This is my code:这是我的代码:

`import UIKit `进口UIKit

class ViewController: UIViewController {

    var activePlayer = 1 //Cross


    @IBAction func action(_ sender: UIButton)
    {
        if (activePlayer == 1)
        {

//I always get an error around this part //我总是在这部分得到一个错误

sender.setImage(UIImage(named:"Cross.png"), for: UIControl.State()) } else { sender.setImage(UIImage(named:"Nought.png"), for: UIControl.State()) } } sender.setImage(UIImage(named:"Cross.png"), for: UIControl.State()) } else { sender.setImage(UIImage(named:"Nought.png"), for: UIControl.State()) } }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
}

` Somebody please help me because I need to know., If it would be of help, I have inserted "Cross.png" into the project and inserted "Nought.png", but when why was writing that part of the code, It never reccomended me to put those names like as a suggestion. `有人请帮助我,因为我需要知道。,如果有帮助,我已将“Cross.png”插入项目并插入“Nought.png”,但是为什么在编写那部分代码时,它从来没有建议我把这些名字作为建议。

Make sure to put the images in the Assets.xcassets folder.确保将图像放在 Assets.xcassets 文件夹中。 Then you will get the suggestions.然后你会得到建议。

If that doesn't work make sure to save images in the Assets.xcassets folder and set image like:如果这不起作用,请确保将图像保存在 Assets.xcassets 文件夹中并将图像设置为:

ImageView.image = image ImageView.image = image

When you type in image, click on the suggestion which says image literal and double click on the picture icon.当您输入图像时,单击显示图像文字的建议,然后双击图片图标。 You should get access to all the images in the Assets.xcassets folder.您应该可以访问 Assets.xcassets 文件夹中的所有图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM