所以我是新來的iOS應用程序開發,只是基本上試圖創建一個真正的應用程序基於我一直在研究的教程和研究。基本上,我有一個視圖控制器,其次是一個導航控制器和一個表視圖控制器(與靜態單元格)鏈接到該導航控制器。目前的方法顯示空白視圖控制器
這裏的目標是僅僅根據條件呈現表視圖控制器(如果存在的話,當前表視圖控制器,否則不要),並且雖然我可以讓它顯示出來,但它是空白的。它沒有任何我添加的標籤或文本框。
因此,例如,這裏是我在我原來的視圖控制器內。什麼我試圖是檢查是否profileExists如果確實如此,目前的表視圖控制器:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Check if user has a profile. If so, go to view page; otherwise, bring up new profile view.
if profileExists != 1 {
// Create new profile page.
if let vc = storyboard?.instantiateViewController(withIdentifier: "CreateProfileController") as? CreateProfileViewController {
present(vc, animated: true, completion: nil)
}
print("Need to create new profile page")
}
}
我有兩個類 - 一個叫CreateProfileViewController(其中我的導航控制器被分配到),和我有一個CreateProfileTableViewController類,這是我的表視圖控制器分配給。我的導航控制器的故事板ID是CreateProfileController
基於該代碼,我期望顯示錶視圖控制器,以及駐留在該表視圖控制器上的標籤和文本框。我可能做錯了什麼地方的表視圖控制器是空的?
編輯:
更新包括CreateProfileTableViewController類:
//
// CreateProfileTableViewController.swift
// Steady Marketing
//
// Created by Alton on 5/11/17.
// Copyright © 2017 SteadyMarketing. All rights reserved.
//
import UIKit
class CreateProfileTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}
/*
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
// Configure the cell...
return cell
}
*/
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// 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.
}
*/
}
哪裏故事板來自於你的代碼?你也必須打電話給self.present。 – Mannopson