I have 2 view controllers, ShipmentsOfResourcesVC and PopupVC. ShipmentsOfResourcesVC is the primary view controller and it is a table view filled with multiple cells. When you press on a cell it's supposed to segue to PopupVC.
The segue works fine and PopupVC appears correctly but the issue I'm having is that when PopupVC appears, the background is transparent for a second and then turns black? I provided a link below to a short 15 second clip on YouTube demonstrating the issue.
This wasn't a problem before when I first created the segue. PopupVC would appear with its standard white background. However, I did start experimenting with changing PopupVC's background such as making it transparent and fiddling around with blur and vibrancy effects but I deleted all of that code and I'm still getting this black background. Also made sure to check in Storyboard that the view's background color is set to white. I've tried deleting the segue and creating a new one with a different name. And I deleted the app on my phone and reinstalled it and this happens on both my device and in the simulator. Any ideas? Possible bug? Using Swift 3 with Xcode 8.2.1.
ShipmentsOfResourcesVC
import UIKit
class ShipmentsOfResourcesVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var myTableView: UITableView!
@IBOutlet weak var falloutCompanionLabel: UILabel!
var resourceList = ResourceList().listOfResources()
var numberOfResources = ResourceList().numberOfResources()
override func viewDidLoad() {
super.viewDidLoad()
myTableView.delegate = self
myTableView.dataSource = self
myTableView.backgroundImage()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination = segue.destination as? PopupVC {
destination.name = resourceList[myTableView.indexPathForSelectedRow!.row]
}
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return numberOfResources
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath)
let row = indexPath.row
cell.textLabel?.text = resourceList[row]
cell.textLabel!.textAlignment = .center
cell.textLabel!.textColor = UIColor.darkGray
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
}
PopupVC
import UIKit
class PopupVC: UIViewController {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var vendorLabel: UILabel!
@IBOutlet weak var locationLabel: UILabel!
@IBOutlet weak var quantityLabel: UILabel!
@IBOutlet weak var map: UIImageView!
@IBOutlet weak var popupView: UIView!
var name = ""
override func viewDidLoad() {
super.viewDidLoad()
popupView.layer.cornerRadius = 20
print("The name is \(name)")
nameLabel.text? = name
switch name {
case "Acid":
vendorLabel.text = "Vendor: Kay"
locationLabel.text = "Location: Bunker Hill"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Adhesive":
vendorLabel.text = "Vendor: Daisy"
locationLabel.text = "Location: Goodneighor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Aluminum":
vendorLabel.text = "Vendor: Arturo"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 50"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Antiseptic":
vendorLabel.text = "Vendor: Doctor Sun"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Asbestos":
vendorLabel.text = "Vendor: Trashcan Carla"
locationLabel.text = "Location: Sanctuary Hills/Bunker Hill"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Ballistic Fiber":
vendorLabel.text = "Vendor: KLEO"
locationLabel.text = "Location: Goodneighor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Ceramic":
vendorLabel.text = "Vendor: Myrna/Percy"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Circuitry":
vendorLabel.text = "Vendor: Daisy"
locationLabel.text = "Location: Goodneighor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Cloth":
vendorLabel.text = "Vendor: Connie"
locationLabel.text = "Location: Abernathy Farm"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Concrete":
vendorLabel.text = "Vendor: Connie"
locationLabel.text = "Location: Abernathy Farm"
quantityLabel.text = "Quantity: 50"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Copper":
vendorLabel.text = "Vendor: Arturo"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Cork":
vendorLabel.text = "Vendor: Moe"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Crystal":
vendorLabel.text = "Vendor: Daisy"
locationLabel.text = "Location: Goodneighor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Fertilizer":
vendorLabel.text = "Vendor: Connie"
locationLabel.text = "Location: Abernathy Farm"
quantityLabel.text = "Quantity: 50"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Fiber Optics":
vendorLabel.text = "Vendor: Proctor Teagan"
locationLabel.text = "Location: The Prydwen"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Fiberglass":
vendorLabel.text = "Vendor: Deb or Lucas"
locationLabel.text = "Location: Bunker Hill"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Gears":
vendorLabel.text = "Vendor: Arturo"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Glass":
vendorLabel.text = "Vendor: Doctor Sun"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 50"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Gold":
vendorLabel.text = "Vendor: Deb"
locationLabel.text = "Location: Bunker Hill"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Lead":
vendorLabel.text = "Vendor: KLEO"
locationLabel.text = "Location: Goodneighor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Leather":
vendorLabel.text = "Vendor: Connie"
locationLabel.text = "Location: Abernathy Farm"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Nuclear Material":
vendorLabel.text = "Vendor: Alexis"
locationLabel.text = "Location: Vault 81"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Oil":
vendorLabel.text = "Vendor: KLEO"
locationLabel.text = "Location: Goodneighbor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Plastic":
vendorLabel.text = "Vendor: Myrna/Percy"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Rubber":
vendorLabel.text = "Vendor: Doctor Sun"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Silver":
vendorLabel.text = "Vendor: Daisy"
locationLabel.text = "Location: Goodneighbor"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Springs":
vendorLabel.text = "Vendor: Myrna/Percy"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Screws":
vendorLabel.text = "Vendor: Arturo"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 25"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Steel":
vendorLabel.text = "Vendor: Myrna/Percy"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 100"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
case "Wood":
vendorLabel.text = "Vendor: Moe"
locationLabel.text = "Location: Diamond City"
quantityLabel.text = "Quantity: 100"
map.image = #imageLiteral(resourceName: "Goodneighbor.gif")
default:
print("That item doesn't exist.")
}
}
@IBAction func xButton(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
}