我的应用程序崩溃了,一定是因为 UIAlertController。
此问题仅发生在 UIAlertController 可用的 iOS 8.x 上。奇怪的是,我的应用程序既不使用 UIAlertViewController 也不使用 UIAlertView。
报告告诉我:
Trying to dismiss UIAlertController <UIAlertController: 0x172c5d80> with unknown presenter.
这怎么会发生?
我想过
但这些案例中没有一个让我崩溃。
崩溃日志告诉我的事实是,操作系统显示了一个将附加到我的应用程序窗口的 AlertView,并且在某些情况下会松开显示 UIAlertViewController 的父 View Controller 。
有什么想法可以找到问题吗?
这里是堆栈跟踪
_________________________________
0 CoreFoundation 0x2bc0c45f __exceptionPreprocess + 127
1 libobjc.A.dylib 0x39c79c8b objc_exception_throw + 36
2 CoreFoundation 0x2bc0c3a5 +[NSException raise:format:] + 110
3 UIKit 0x2f4ad13d -[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:] + 414
4 UIKit 0x2f4acf97 -[UIAlertController _dismissAnimated:triggeringAction:] + 28
5 UIKit 0x2f590a0b -[_UIAlertControllerActionView touchesEnded:withEvent:] + 160
6 UIKit 0x2f159567 -[UIWindow _sendTouchesForEvent:] + 520
7 UIKit 0x2f152e31 -[UIWindow sendEvent:] + 542
8 UIKit 0x2f129759 -[UIApplication sendEvent:] + 194
9 UIKit 0x2f39d2f9 _UIApplicationHandleEventFromQueueEvent + 14166
10 UIKit 0x2f1281a9 _UIApplicationHandleEventQueue + 1350
11 CoreFoundation 0x2bbd2fbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
12 CoreFoundation 0x2bbd23cf __CFRunLoopDoSources0 + 216
13 CoreFoundation 0x2bbd0a35 __CFRunLoopRun + 770
14 CoreFoundation 0x2bb1e3b1 CFRunLoopRunSpecific + 474
15 CoreFoundation 0x2bb1e1c3 CFRunLoopRunInMode + 104
16 GraphicsServices 0x3308d201 GSEventRunModal + 134
17 UIKit 0x2f18843d UIApplicationMain + 1438
18 MyApp 0x00028a07 main (main.mm:16)
编辑
holes 询问我的窗口初始化。这是我的 AppDelegate 的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[MyAppCustomWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_mainViewController = [[MyAppContainerViewController alloc] initWithNibName:nil bundle:nil];
_mainStatusBarVC = [[MyAppStatusBarVC alloc] initWithRootVC:_mainViewController];
[self.window setRootViewController:_mainStatusBarVC];
[self.window makeKeyAndVisible];
return YES;
}
最佳答案
我敢打赌你的崩溃发生在 iPad 上。
在 iPad 上,从 iOS8 开始,UIActionSheet 似乎由 UIAlertController 处理
有了这段代码,
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 1) return; // Cancel button
[self doSomeViewControllerDismisses];
}
我的应用程序崩溃并出现与您遇到的相同的错误。
为了防止这种情况,我只是在下一次 MainThread 执行时调度复杂的关闭调用,为隐藏的 UIAlertViewController 提供正确释放的机会。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 1) return; // Cancel button
dispatch_async(dispatch_get_main_queue(), ^{
[self doSomeViewControllerDismisses];
});
}
关于ios - 试图用未知的演示者解雇 UIAlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29649223/
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上
我有一个Rails应用程序,它在名为properties的字段中存储序列化哈希。虽然哈希键是未知的,所以我不知道有什么方法可以通过强参数实现这一点。谷歌搜索时,我发现了这个:https://github.com/rails/rails/issues/9454,但我想不出具体的解决方案。基本上,我的问题是:如何配置强参数以允许使用未知键的散列?感谢大家的帮助! 最佳答案 我最近遇到了同样的问题,我使用来自https://github.com/rails/rails/issues/9454的@fxn方法解决了它对于以properties
在他们的网站上找不到任何内容。我主要只是想看看哪个值得一试(当然是RIA)。谢谢 最佳答案 SproutCoredemos 关于ruby-是否有SproutCore或Cappuccino的现场演示/示例应用程序,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1419788/
尝试通过SSL连接到ImgurAPI时出现错误。这是代码和错误:API_URI=URI.parse('https://api.imgur.com')API_PUBLIC_KEY='Client-ID--'ENDPOINTS={:image=>'/3/image',:gallery=>'/3/gallery'}#Public:Uploadanimage##args-Theimagepathfortheimagetoupload#defupload(image_path)http=Net::HTTP.new(API_URI.host)http.use_ssl=truehttp.verify
我不是Ruby专家,但想弄清楚发生了什么,因为我试图让指南针在节点应用程序中工作,但我的Ruby似乎坏了。打字:ruby--version让我:ruby2.1.1p76(2014-02-24revision45161)[x86_64-darwin13.0]我安装了Homebrew,之前遇到过Ruby版本的问题,但它似乎已安装并且可以正常工作。但是,当我使用gem输入请求时,出现此错误:$gem-hErrorloadingRubyGemsplugin"/Users/user_dir/.rvm/gems/ruby-2.1.1@global/gems/executable-hooks-1.3
当我将IO::popen与不存在的命令一起使用时,我在屏幕上打印了一条错误消息:irb>IO.popen"fakefake"#=>#irb>(irb):1:commandnotfound:fakefake有什么方法可以捕获此错误,以便我可以在脚本中进行检查? 最佳答案 是:升级到ruby1.9。如果您在1.9中运行它,则会引发Errno::ENOENT,您将能够拯救它。(编辑)这是在1.8中的一种hackish方式:error=IO.pipe$stderr.reopenerror[1]pipe=IO.popen'qwe'#
当我尝试使用“套接字”库中的方法“read_nonblock”时出现以下错误IO::EAGAINWaitReadable:Resourcetemporarilyunavailable-readwouldblock但是当我通过终端上的IRB尝试时它工作正常如何让它读取缓冲区? 最佳答案 IgetthefollowingerrorwhenItrytousethemethod"read_nonblock"fromthe"socket"library当缓冲区中的数据未准备好时,这是预期的行为。由于异常IO::EAGAINWaitReadab