gpt4 book ai didi

objective-c - 应用程序在 [UIAlertView show] 上崩溃

转载 作者:搜寻专家 更新时间:2023-10-30 19:56:51 25 4
gpt4 key购买 nike

我的应用程序在我想要显示警报时立即崩溃。这段代码非常基础,我找不到任何问题。有人可以验证我是否做错了什么吗?

@implementation SampleClass
- (void) showAlert
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Make an informed choice"
message:@"Descriptive text"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
@end

堆栈是:

0   libobjc.A.dylib                 0x3006bc98 objc_msgSend + 16
1 NESampleApp 0x002ec5bc 0x1000 + 3061180
2 UIKit 0x35584bee -[UIWindow _sendTouchesForEvent:] + 362
3 UIKit 0x35584568 -[UIWindow sendEvent:] + 256
4 UIKit 0x3556d30c -[UIApplication sendEvent:] + 292
5 UIKit 0x3556cc4c _UIApplicationHandleEvent + 5084
6 GraphicsServices 0x35350e70 PurpleEventCallback + 660
7 CoreFoundation 0x3599da90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
8 CoreFoundation 0x3599f838 __CFRunLoopDoSource1 + 160
9 CoreFoundation 0x359a0606 __CFRunLoopRun + 514
10 CoreFoundation 0x35930ebc CFRunLoopRunSpecific + 224
11 CoreFoundation 0x35930dc4 CFRunLoopRunInMode + 52
12 GraphicsServices 0x35350418 GSEventRunModal + 108
13 GraphicsServices 0x353504c4 GSEventRun + 56
14 UIKit 0x35597d62 -[UIApplication _run] + 398
15 UIKit 0x35595800 UIApplicationMain + 664
16 NESampleApp 0x0017d10c 0x1000 + 1556748
17 NESampleApp 0x007d3720 0x1000 + 8202016

更新:将委托(delegate)设置为 nil 后,我在崩溃的同时获得了更多信息:

<Error>: -[CALayer isTransformGestureInput]: unrecognized selector sent to instance 0xb4c8a0
<Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer isTransformGestureInput]: unrecognized selector sent to instance 0xb4c8a0'

最佳答案

试试这个而不是 [alert show]

[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];

关于objective-c - 应用程序在 [UIAlertView show] 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6071057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com