I'm trying to write a simple bar code scanning app using a hardware attachment to an iOS device.
The restriction is that I can only have one view controller descending from the device events, but I need 3 or 4 tabbed views responding to the device.
So in essence - I need two or more views with one view controller, and I can't work out how to do it.
I created a stand alone app, embedded it in a tab bar, then added a second tab and assigned the view controller to it as well.
I then create a label on each view, 'greenlabel' and 'bluelabel'.
Layout here :
The following is in my ViewController.swift:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var GreenLabel: UILabel!
@IBOutlet weak var BlueLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
GreenLabel.text = "Green"
BlueLabel.text = "Blue" // <--- crashes here because BlueLabel is nil
// 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.
}
}
How or what do I do to allow access to both views from the same code?
Thanks.
The restriction is that I can only have one view controller descending from the device events, but I need 3 or 4 tabbed views responding to the device.
So in essence - I need two or more views with one view controller, and I can't work out how to do it.
I created a stand alone app, embedded it in a tab bar, then added a second tab and assigned the view controller to it as well.
I then create a label on each view, 'greenlabel' and 'bluelabel'.
Layout here :
The following is in my ViewController.swift:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var GreenLabel: UILabel!
@IBOutlet weak var BlueLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
GreenLabel.text = "Green"
BlueLabel.text = "Blue" // <--- crashes here because BlueLabel is nil
// 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.
}
}
How or what do I do to allow access to both views from the same code?
Thanks.