Я хочу изменить текст в метках с текстом в двух массивах. Когда я запускаю этот код, приложение ничего не показывает. Как я могу это сделать? Я импортирую индекс с помощью перехода из TableView.
import UIKit
class DeviceDetailViewController: UIViewController {
var devices: [String] = ["iPhone 11 Pro", "iPad Pro", "Apple Watch series 5", "AirPods Pro", "MacBook Pro", "iMac Pro"]
var devicesDescription: [String] = ["The iPhone 11 Pro is Apple's most powerful phone that come in a one-hand-friendly size. It has a triple-lens camera to capture best-in-class photos and video from a variety of perspectives, a new night mode to enhance low-light photography and extra battery life prowess.", "The 11-inch iPad Pro features a resolution of 2388 x 1668, while the 12.9-inch model has a resolution of 2732 x 2048, and both have 264 pixels per inch like prior models. The iPad Pro displays feature 600 nits brightness, 1.8 percent reflectivity, an antireflective coating, and a fingerprint-resistant coating.", "The Apple Watch is a smartwatch that operates as a small wearable computing device worn on a user's wrist. ... While most analysts expected the device to be released under the Apple iWatch moniker, Apple surprised many by deviating from the i pattern of naming its new devices like the iPod, iPhone and iPad.", "The AirPods Pro have a sensor on the back that can auto-detect when it's removed from the ear and pauses your music automatically. The AirPods Pro have two tiny microphones both on the inside and on the outside, and they work in the same way that all active noise cancelling headphones do.", "Each MacBook Pro has a high-resolution, LED-backlit glossy widescreen display. ... However, Apple provides a Retina Display option for the MacBook Pro that boosts resolution to 2,880 by 1,800 pixels. For power, the MacBook relies on a built-in lithium-polymer battery and a MagSafe 2 power adapter.", "It touts its 27-inch 5K Retina display, an 8-core Intel Xeon W processor (CPU), AMD Radeon Vega 56 (8GB) graphics (GPU), 32GB of error-correcting code (ECC) memory and a 1TB solid-state drive (SSD). The iMac Pro internal components are aimed specifically at professionals."]
var deviceImages = ["iphone11"]
var deviceIndex = 1
@IBOutlet weak var deviceLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var deviceImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
print("index: \(deviceIndex)")
titleLabel.text = devices[deviceIndex]
deviceLabel.text = devicesDescription[deviceIndex]
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}