ios - 为新的 View Controller 创建一个类

标签 ios swift uiviewcontroller

我的 Xcode 项目带有默认值:

class ViewController: UIViewController

然后我用 ID next 创建了一个新的 View Controller 。

如何创建一个类似于项目已经创建的类,但用于我的 View Controller next

我认为它看起来像:

class next: UIviewcontroller

最佳答案

如果我明白你想做什么,那么你需要创建一个类 NextViewController 并覆盖方法 viewDidLoaddidReceiveMemoryWarning ,如下所示:

class NextViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

然后在 Storyboard的 Identity inspector 选项卡中选择为您的 ViewController 创建的类,如下所示:

enter image description here

关于ios - 为新的 View Controller 创建一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33462039/

相关文章:

iphone - CLPlacemark - 国家缩写?

iOS 模拟器、CLLocationManager、startUpdatingLocation 和 locationManager :didUpdateLocations

ios - 当 VC 链接到 TabBarController 时,IBOutlet 和 IBAction 被禁用

ios - 如何可靠地检测到 UIViewController 已被关闭

JavascriptCore:在 JSExport 中将 javascript 函数作为参数传递

iphone - TTCatalog(Three20)不会运行

ios - 在ios中使用swift 3进行Google和Facebook Firebase登录身份验证

swift - 为自定义私有(private)类实现 Equatable - Swift

ios - 链接 UIAlertAction 打开另一个 ViewController

ios - 无法从 UITabBarController 中关闭 UIViewController