2016-04-09 4 views
0

В AppDelegate Я проверяю, будет ли список сеансов пользователей, а затем переходить на домашнюю страницу пользователя (отображать две кнопки), а затем на страницу входа. Форма входа в систему после входа в систему для пользователя.Swift: Исключение при навигации UIViewController в UITableViewController

LoginView является UIViewController домашний каталог является UIViewController

Когда я нажимаю «Получить отчет» на домашний каталог я хочу показать некоторый отчет в таблице ReportView является UITableViewController

Вот код приложения

AppDelegate

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 


    let mainStoryboard:UIStoryboard = UIStoryboard (name: "Main", bundle: nil) 

    let isUserLoggedIn:Bool = NSUserDefaults.standardUserDefaults().boolForKey("isUserLoggedIn") 

    if(!isUserLoggedIn){ 
     let loginVC = mainStoryboard.instantiateViewControllerWithIdentifier("loginvc") as! LoginVC 

     window!.rootViewController = loginVC 

     window!.makeKeyAndVisible(); 

    }else{ 

let userhome = mainStoryboard.instantiateViewControllerWithIdentifier("userhome") as! UserHomeViewController 

      window!.rootViewController = userhome 
      window!.makeKeyAndVisible(); 


} 


    return true 
} 

LoginView

После Succes ответа от службы отдыха

let userhome = self.storyboard?.instantiateViewControllerWithIdentifier("user home") as! UserHomeViewController 
        dispatch_async(dispatch_get_main_queue()) { 
         self.presentViewController(userhome, animated: true, completion: nil) 
        } 

О Получить отчет У меня есть

@IBAction func getReport(sender: UIButton) { 

    let reportview = self.storyboard?.instantiateViewControllerWithIdentifier("reportvc") as! ReportViewController 

    //Excepetion 
    self.presentViewController(reportview, animated: true, completion: nil) 

    //nothing happens 
    //self.navigationController?.presentViewController(reportview, animated: true, completion: nil) 
} 

ReportViewCOntroller просто еще отметить. Методы Base реализованы

class FSMSOListTableViewController: UITableViewController { 

var soList = [String]() 


override func viewDidLoad() { 
    super.viewDidLoad() 

    soList = ["E7677","E7678","E7679","E7680"] 

    self.tableView.registerClass(UITableView.self, forCellReuseIdentifier: "cell") 


     } 

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

// MARK: - Table view data source 

override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
    return 1 
} 

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return soList.count 

} 
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier(
     "cell", 
     forIndexPath: indexPath) //make the cell 

    cell.textLabel?.text = self.soList[indexPath.row] 

    return cell 
} 

Исключение составляет

2016-04-09 12: 26: 19,415 AkunaConnect [13163: 943688] * Нагрузочного приложение из-за неперехваченное исключение 'NSInvalidArgumentException', причины : 'должен пройти класс типа UITableViewCell' * Первый стек вызова броска: (0 CoreFoundation 0x0000000102cf9e65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000104a39deb objc_exception_throw + 48 2 CoreFoundation 0x0000000102cf9d9d + [NSException повышение: формат:] + 205 3 UIKit 0x0000000103662b01 - [UITableView RegisterClass: forCellReuseIdentifier:] + 285 4 AkunaConnect 0x0000000102ad783f _TFC12AkunaConnect28FSMSOListTableViewController11viewDidLoadfS0_FT_T_ + 623 5 AkunaConnect 0x0000000102ad78f2 _TToFC12AkunaConnect28FSMSOListTableViewController11viewDidLoadfS0_FT_T_ + 34 6 UIKit 0x00000001036acf98 - [UIViewController loadViewIfRequired] + 1 198 7 UIKit 0x00000001036ad2e7 - [UIViewController вид] + 27 8 UIKit 0x0000000103e57f87 - [_ UIFullscreenPresentationController _setPresentedViewController:] + 87 9 UIKit 0x0000000103 67cf62 - [UIPresentationController initWithPresentedViewController: presentingViewController:] + 133 10 UIKit 0x00000001036bfc8c - [UIViewController _presentViewController: withAnimationController: завершение:] + 4002 11 UIKit 0x00000001036c2f2c - [UIViewController _performCoordinatedPresentOrDismiss: анимированные:] + 489 12 UIKit 0x00000001036c2a3b - [UIViewController presentViewController: анимированный: завершение:] + 179 13 AkunaConnect 0x0000000102ad688d _TFC12AkunaConnect17FLMViewController9getReportfS0_FCSo8UIButtonT_ + 621 14 AkunaConnect 0x0000000102ad69ea _TToFC12AkunaConnect17FLMViewController9getReportfS0_FCSo8UIButtonT_ + 58 15 UIKit 0x0000000103518194 - [UIApplication sendAction: до: от: forEvent:] + 92 16 UIKit 0x0000000 1036876fc - [UIControl sendAction: до: forEvent:] + 67 17 UIKit 0x00000001036879c8 - [UIControl _sendActionsForEvents: withEvent:] + 311 18 UIKit 0x0000000103686af8 - [UIControl touchesEnded: withEvent:] + 601 19 UIKit 0x000000010358749b - [UIWindow _sendTouchesForEvent: ] + 835 20 UIKit 0x00000001035881d0 - [UIWindow SendEvent:] + 865 21 UIKit 0x0000000103536b66 - [UIApplication SendEvent:] + 263 22 UIKit 0x0000000103510d97 _UIApplicationHandleEventQueue + 6844 23 CoreFoundation 0x0000000102c25a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 24 CoreFoundation 0x0000000102c1b95c __CFRunLoopDoSources0 + 556 25 C oreFoundation 0x0000000102c1ae13 __CFRunLoopRun + 867 26 CoreFoundation 0x0000000102c1a828 CFRunLoopRunSpecific + 488 27 GraphicsServices 0x000000010730fad2 GSEventRunModal + 161 28 UIKit 0x0000000103516610 UIApplicationMain + 171 29 AkunaConnect 0x0000000102ad96cd основной + 109 30 libdyld.dylib 0x000000010554292d старт + 1 31 ??? 0x0000000000000001 0x0 + 1 ) LibC++ abi.dylib: оканчивающиеся неперехваченного исключением типа NSException (lldb)

ответ

1

Вы пытаетесь зарегистрировать экземпляр класса TableView как UITableViewCell в ** FSMSOListTableViewController ** класс ,

Это может помочь вам:

override func viewDidLoad() { 
    super.viewDidLoad() 
    soList = ["E7677","E7678","E7679","E7680"] 
    self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") 

} 
+0

Я получаю ошибку компиляции для UITableViewCellStyleDefault но работал под 'self.tableView.registerClass (UITableViewCell.self, forCellReuseIdentifier: "клетка")' – user2672763

+0

Я отредактировал мой ответ.. –

Смежные вопросы