简体   繁体   English

我在xcode中遇到错误(没有可用的重载)

[英]I am getting an error in xcode (no available overloads)

import UIKit
class ViewController: UIViewController {
   @IBOutlet weak var leftimageview: UIImageView!
   @IBOutlet weak var rightimageview: UIImageView!

   @IBOutlet weak var leftscorelabel: UIStackView!
   @IBOutlet weak var rightscorelabel: UIStackView!

   override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
   }

   override func didReceiveMemoryWarnng() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
   }

   @IBAction func resetbutton(_sender: Any) {
      print("resetgame")
      leftimageview.image = UIImage()
   }
}

I am getting this error when I am trying to change the picture displayed when the button in my project is pressed. 当我尝试更改按项目中的按钮时显示的图片时,出现此错误。

You can use a UIImage like this in one of 2 ways: 您可以通过以下两种方式之一使用UIImage

  • Using the UIImage(named:) constructor 使用UIImage(named:)构造函数

    leftimageview.image = UIImage(named: "rosemary")

  • The more Swifty way, using an image literal 更快捷的方法,使用图像文字

    leftimageview.image = #imageLiteral(resourceName: "rosemary")

You can use a Swift Image Literal in Xcode by starting to type Image Literal and use the autocomplete and select your image 您可以通过开始键入Image Literal并使用自动完成功能并选择您的图像来在Xcode中使用Swift Image Literal

如果您使用的是图片文字,则无需使用UIImage构造函数,只需执行leftimageview.image = rosemary ,其中rosemary是屏幕快照中的图片文字(与图片预览一起显示,实际上是#imageLiteral(resourceName: "rosemary")

暂无
暂无

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

相关问题 参数标签 '(rawValue:)' 不匹配任何可用的重载(xcode 错误) - Argument labels '(rawValue:)' do not match any available overloads (xcode error) 与ioscharts不匹配可用的重载错误 - Not matching available overloads error with ioscharts 使用tableview时xcode中可用的重载 - available overloads in xcode when using tableview 为什么我在 Xcode 的 pod init 期间收到加载错误? - Why am I getting a load error during pod init in Xcode? 参数标签“(MDLObject:)”与 Xcode 10 中的任何可用重载都不匹配 - Argument labels '(MDLObject:)' do not match any available overloads in Xcode 10 当我尝试在设备中启动我的应用程序时,在xcode中由于启动选项nil出现错误? - when I am trying to launch my app in my device and I am getting the error as launch option nil in my xcode? 为什么在xcode 7.2.1中创建项目存档时出现此链接器错误? - why am i getting this linker error while creating archive of my project in xcode 7.2.1 为什么我在 Xcode 调试控制台中收到错误消息“无法识别的选择器” - Why am I getting the error message "unrecognised selector" in my Xcode debug console 错误:参数标签 '(_:, _:)' 与任何可用的重载不匹配 - Error: Argument labels '(_:, _:)' do not match any available overloads swift cgsize错误参数标签'(_ :, _ :)'与任何可用的重载都不匹配 - swift cgsize error Argument labels '(_:, _:)' do not match any available overloads
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM