2017-01-29 9 views
0

Я пытаюсь показать свой «ProtectedViewController».Ошибка просмотра ViewController

let storyboard = UIStoryboard(name: "Main", bundle: nil) 
let controller: UIViewController = storyboard.instantiateViewController(withIdentifier: "Protected") as! ProtectedPageViewController 
self.present(controller, animated: true, completion: nil) 

Когда я пытаюсь отобразить его хлопков ошибок на этапе

self.present(controller, animated: true, completion: nil) 

, как на скриншоте ниже:

error Код ниже не работает слишком:

let pvc = ProtectedPageViewController() 
self.present(pvc, animated: true, completion: nil) 

Такая же ошибка. Пробовала все.

Ошибка из трассировки стека:

*** First throw call stack: 
(
    0 CoreFoundation      0x0000000108a2c34b __exceptionPreprocess + 171 
    1 libobjc.A.dylib      0x000000010807021e objc_exception_throw + 48 
    2 CoreFoundation      0x0000000108a30442 +[NSException raise:format:arguments:] + 98 
    3 Foundation       0x0000000107c06edd -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 
    4 UIKit        0x0000000109be1942 -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 165 
    5 UIKit        0x000000010934ec14 -[UIKeyboardImpl setDelegate:force:] + 1404 
    6 UIKit        0x0000000109776152 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 981 
    7 UIKit        0x000000010977f95c -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 498 
    8 UIKit        0x00000001092409b7 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1178 
    9 UIKit        0x0000000109242702 -[UIViewController _presentViewController:withAnimationController:completion:] + 4971 
    10 UIKit        0x00000001092456df -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 530 
    11 UIKit        0x00000001092451c5 -[UIViewController presentViewController:animated:completion:] + 179 
    12 Registration      0x0000000107a7208a _TFFC12Registration23LoginPageViewController17loginButtonTappedFPs9AnyObject_T_U_FTGSqV10Foundation4Data_GSqCSo11URLResponse_GSqPs5Error___T_ + 3482 
    13 Registration      0x0000000107a695fb _TTRXFo_oGSqV10Foundation4Data_oGSqCSo11URLResponse_oGSqPs5Error____XFdCb_dGSqCSo6NSData_dGSqS1__dGSqCSo7NSError___ + 203 
    14 CFNetwork       0x000000010b8756b0 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19 
    15 CFNetwork       0x000000010b874f5c __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 308 
    16 Foundation       0x0000000107b742cd __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7 
    17 Foundation       0x0000000107b73faf -[NSBlockOperation main] + 101 
    18 Foundation       0x0000000107b726ac -[__NSOperationInternal _start:] + 672 
    19 Foundation       0x0000000107b6e5ef __NSOQSchedule_f + 201 
    20 libdispatch.dylib     0x000000010c2600cd _dispatch_client_callout + 8 
    21 libdispatch.dylib     0x000000010c23de6b _dispatch_queue_serial_drain + 236 
    22 libdispatch.dylib     0x000000010c23eb9f _dispatch_queue_invoke + 1073 
    23 libdispatch.dylib     0x000000010c2413b7 _dispatch_root_queue_drain + 720 
    24 libdispatch.dylib     0x000000010c24108b _dispatch_worker_thread3 + 123 
    25 libsystem_pthread.dylib    0x000000010c60a712 _pthread_wqthread + 1299 
    26 libsystem_pthread.dylib    0x000000010c60a1ed start_wqthread + 13 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

Пожалуйста, помогите мне найти способ, чтобы исправить это.

Заранее благодарен!

P.S .: Использование IOS 10.0 и Swift 3

+1

На скриншоте есть стоп-кадр, скопируйте и вставьте сообщение об ошибке в этот стек. – luk2302

ответ

1

StackTrace показывает что-то в NSURLSession контексте. Представляете ли вы ViewController из основного потока или из какого-то рабочего потока?

Пожалуйста, проверьте выполнение вашей презентации вызов из главного потока преуспевает:

DispatchQueue.main.async { 
    // here your presentation call, e.g. 
    self.present(controller, animated: true, completion: nil) 
} 

Если нет, то вы должны опубликовать полное исключение (из окна вывода) и/или немного больше кода (более из область, которую вы представляете контроллеру)

+0

Большое спасибо. Это хорошо работает))) –

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

  • Нет связанных вопросов^_^