我希望我的应用程序在收到一些来电时显示 IncomingCall ViewController。
这是我用来显示来电的代码。来 self 的 ContactsViewController,当来电发生时它是事件 View 。
- (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:eeshaMiss12@ekiga.net>!!
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
我是初学者,如有任何建议,我们将不胜感激。提前致谢
最佳答案
您正在经历崩溃,因为您正在以编程方式分配您的 ContactsViewController,而不是从 storyboard 中使用。
当你这样做时:
ContactsViewController *incomingCallVC = [[ContactsViewController alloc]init];
[incomingCallVC showIncomigCallVC];
您正在创建 ContactsViewController 的实例,与我们在 storyboard 中创建的实例无关。
有可能克服这一点,但是,您正在尝试对 viewController 进行 segue 调用,它只加载到内存中,但不可见根本。那永远行不通,它总是会崩溃。
我建议立即显示您的 viewController,无论 segue 后面是什么,而不是创建一个 viewController 并用 segue 显示它。
编辑:
使用下面的代码,您应该能够在回调函数的末尾呈现您想要的 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];
});
关于ios - 无法为我的 iOS VoIP 应用程序显示 onComingCall ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41680317/
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r