UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Project 2 issue

Forums > 100 Days of Swift

i have this code in my xcode wheni run its showing white blanck screen not flags at all, if i remove askQuestion() call func all flags will appreat on simulator.... could any one help me please..

import UIKit

class ViewController: UIViewController {

@IBOutlet var button1: UIButton!

@IBOutlet var button2: UIButton!

@IBOutlet var button3: UIButton!
var countries = [String]()
var score = 0

override func viewDidLoad() {
    super.viewDidLoad()

    countries += ["estonia", "frane", "germany", "ireland", "italy", "monaco", "nigeria", "poland","russia", "spain", "us", "uk"]

    askQuestion() // this point has issue i have tried run command everycode i have written to find this issue...
}

func askQuestion() { button1.setImage(UIImage(named: countries[0]), for: .normal) button2.setImage(UIImage(named: countries[1]), for: .normal) button3.setImage(UIImage(named: countries[2]), for: .normal) }

}

3      

SOLVED!!!

flag name on the image is capital letter not small letters see code below.

countries += ["Estonia", "Frane", "Germany", "Ireland", "Italy", "Monaco", "Nigeria", "Poland","Russia", "Spain", "US", "UK"]

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.