XCode 8.3.2故事板UI元素不会出现在模拟器中

时间:2017-05-10 05:19:42

标签: ios swift

免责声明:我发现了其中一些问题,但没有一个问题有帮助。

就像标题所说,我的CarDetailViewController的故事板UI元素不会出现在模拟器中,但它们会在项目中的其他视图控制器中出现。

vc in question

overall project

代码:

import UIKit
import EventKit
import CoreData


class CarDetailViewController: UIViewController, 
UIImagePickerControllerDelegate, UINavigationControllerDelegate, 
NSFetchedResultsControllerDelegate {


/* -------------------------------------------------------------------------------------------------------- */
let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

/* -------------------------------------------------------------------------------------------------------- */

@IBOutlet weak var myImageView: UIImageView!
let picker = UIImagePickerController()
@IBOutlet weak var carLabel: UILabel!

@IBAction func photoFromLibrary(_ sender: UIButton) {
    picker.allowsEditing = false
    picker.sourceType = .photoLibrary
    picker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary)!
    present(picker, animated: true, completion: nil)

}

override func viewDidLoad() {
    super.viewDidLoad()
    picker.delegate = self
    self.view = UIImageView(image: UIImage(named: "Landing.png"))
    // Do any additional setup after loading the view.

}

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

@nonobjc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: AnyObject])
{
    let chosenImage = info[UIImagePickerControllerOriginalImage]
    myImageView.contentMode = .scaleAspectFit //3
    myImageView.image = chosenImage as? UIImage //4
    dismiss(animated: true, completion: nil) //5
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController)
{
    dismiss(animated: true, completion: nil)
}


/*
// 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.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

}

2 个答案:

答案 0 :(得分:0)

试试这个:

删除此行:

select count(f.CUSTOMER_ID) as agg from customerType f INNER JOIN 
customer t ON f.CUSTOMERID=t.CUSTOMERID WHERE 
f.type='VVIP' and t.BookingDate BETWEEN 
TO_DATE('10/01/2016','MM/DD/YYYY') AND TO_DATE('10/02/2016','MM/DD/YYYY');

您需要将背景图片设置为

self.view = UIImageView(image: UIImage(named: "Landing.png"))

答案 1 :(得分:0)

您没有将图像视图分配到uiview中 所以而不是

self.view = UIImageView(image: UIImage(named: "Landing.png"))

您有以下选择:

  1. 您应该在您的uiview中添加uiimageview并为其分配该图像。
  2. 您可以使用此图片创建渐变背景色。
  3. 恕我直言使用第一种方法,因为第二种方法可能导致不同设备的解决问题

    修改更新 而不是按照以下

    初始化vc
    let destination = CarDetailViewController() // Your destination
    

    尝试执行以下操作

    let storyboard = UIStoryboard(name: <Storyboard-name>, bundle: nil)
    let inquireViewController = storyboard.instantiateViewController(withIdentifier: String(describing:CarDetailViewController.self)) as! CarDetailViewController