2017-01-16 9 views
2

Appが着信コールを受信したときにIncomingCall ViewControllerを表示するようにします。iOS VoIPアプリケーションのonComingCall ViewControllerを表示できません

これは、着信を表示するために私が使用するコードです。着信コールが着信するときにアクティブビューである私のContactsViewControllerから。

- (void)showIncomigCallVC{ 
    [self performSegueWithIdentifier:@"segueToIncomingCallVC" sender:nil]; 
} 

これはライブラリによって呼び出される私のコードです。

/* Callback called by the library upon receiving incoming call */ 
static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, 
         pjsip_rx_data *rdata) 
{ 
    pjsua_call_info ci; 

    PJ_UNUSED_ARG(acc_id); 
    PJ_UNUSED_ARG(rdata); 

    pjsua_call_get_info(call_id, &ci); 



    PJ_LOG(3,(THIS_FILE, "....\n\n\n Incoming call from %.*s!! \n\n\n", 
      (int)ci.remote_info.slen, 
      ci.remote_info.ptr)); 

    ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init]; 
    [incomingCallVC showIncomigCallVC]; 

    /* Automatically answer incoming calls with 200/OK */ 
    pjsua_call_answer(call_id, 200, NULL, NULL); 
} 

そして、これは私のコンソール出力です:私は初心者です

20:39:37.482  XCPjsua.c ...... 


Incoming call from <sip:[email protected]>!! 



2017-01-16 20:39:37.494 simpleVoIP[922:19652] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<ContactsViewController: 0x7bea3d00>) has no segue with identifier 'segueToIncomingCallVC'' 
*** First throw call stack: 
(
    0 CoreFoundation      0x03a14212 __exceptionPreprocess + 194 
    1 libobjc.A.dylib      0x034d3e66 objc_exception_throw + 52 
    2 UIKit        0x01a69893 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0 
    3 simpleVoIP       0x00089ba6 -[ContactsViewController showIncomigCallVC] + 70 
    4 simpleVoIP       0x00086caf on_incoming_call + 255 
    5 simpleVoIP       0x000fc273 pjsua_call_on_incoming + 3811 
    6 simpleVoIP       0x00103294 mod_pjsua_on_rx_request + 84 
    7 simpleVoIP       0x0012938f pjsip_endpt_process_rx_data + 351 
    8 simpleVoIP       0x00128bf2 endpt_on_rx_msg + 546 
    9 simpleVoIP       0x0012fba1 pjsip_tpmgr_receive_packet + 849 
    10 simpleVoIP       0x001315ec udp_on_read_complete + 316 
    11 simpleVoIP       0x0014b8e0 ioqueue_dispatch_read_event + 704 
    12 simpleVoIP       0x0014d5b2 pj_ioqueue_poll + 946 
    13 simpleVoIP       0x001290c3 pjsip_endpt_handle_events2 + 163 
    14 simpleVoIP       0x00102023 worker_thread + 99 
    15 simpleVoIP       0x0014eb96 thread_main + 86 
    16 libsystem_pthread.dylib    0x04c8a11b _pthread_body + 184 
    17 libsystem_pthread.dylib    0x04c8a063 _pthread_body + 0 
    18 libsystem_pthread.dylib    0x04c8993e thread_start + 34 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

あなたがプログラム的に配分されているので、任意の勧告は、おかげでアドバンス

+0

だけエラー読む:あなたはshowIncomigCallVC'は識別子 '' segueToIncomingCallVCで設定ストーリーボードに何のセグエを持っていない '呼び出しているところから、' ContactsViewController'を。私たちの問題を解決するには、 'ContactsViewController'をストーリーボードに表示できますか?特に、あなたがセグを設定している部分。私はこのような何かを期待しています:http://imgur.com/a/SMKjT – dirtydanee

+0

ええ..!私は表示することができますし、応答のためにありがとう – Eesha

+0

@ dirtydaneeこれを参照してください:https://drive.google.com/open?id=0B9eGVWZOsrOmRHVsMENTNTBQTHc – Eesha

答えて

2

にあなたがクラッシュを経験している...理解されるであろうあなたのContactsViewControllerの代わりに、storyboardから使用してください。

あなたがこれを行うときは:あなたはContactsViewControllerのインスタンスを作成している

ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init]; 
[incomingCallVC showIncomigCallVC]; 

を、何が私たちのstoryboardで作成されたものとは何の関係もありません。
これで克服することは可能ですが、viewControllersegueコールを作成しようとしていますが、メモリにロードされているものの、まったく表示されません。それは決してうまくいかず、いつもクラッシュするでしょう。

viewControllerを作成する代わりに、その直後にあるものが何であっても、viewControllerを表示して、それをセグに表示することをおすすめします。

EDIT:以下のコードを使用して

、あなたのコールバック関数の終わりからご希望のUIViewControllerサブクラスを提示することができるはずです。

// Lets get keywindow 
UIWindow* keyWindow = [[[UIApplication sharedApplication] delegate] window]; 
keyWindow.frame = [UIScreen mainScreen].bounds; 

// Lets get `IncomingCallViewController` from storyboard 
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"TheNameOfYourStoryboard" bundle:nil]; 
// do not forget to set the identifier of your viewController on the storyboard as "IncomingCallViewController" 
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"IncomingCallViewController"]; 
// Lets present the keyWindow from the main thread 
dispatch_async(dispatch_get_main_queue(), ^{ 
    keyWindow.rootViewController = vc; 
    [keyWindow makeKeyAndVisible]; 
}); 
+0

これを試してみてください。 – Eesha

+0

あなたの進歩について教えてください。 – dirtydanee

+0

あなたは、このコーディングを行う必要があることを意味しますか? ContactsViewController * incomingCallVC; [incomingCallVC showIncomigCallVC]; – Eesha

関連する問題