How to subclass UITableViewController in Swift

后端 未结 9 1830
栀梦
栀梦 2020-12-23 11:42

I want to subclass UITableViewController and be able to instantiate it by calling a default initializer with no arguments.

class TestViewController: UITableV         


        
9条回答
  •  暖寄归人
    2020-12-23 12:16

    Not sure it is related to your question, but in case you want to init UITableView controller with xib, Xcode 6.3 beta 4 Release Notes provide a workaround:

    • In your Swift project, create a new empty iOS Objective-C file. This will trigger a sheet asking you “Would you like to configure an Objective-C bridging header.”
    • Tap “Yes” to create a bridging header
    • Inside [YOURPROJECTNAME]-Bridging-Header.h add the following code:
    @import UIKit;
    @interface UITableViewController() // Extend UITableViewController to work around 19775924
    - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil NS_DESIGNATED_INITIALIZER ;
    @end
    

提交回复
热议问题