gpt4 book ai didi

ios - UIApplicationMain 错误上的 SIGABRT

转载 作者:行者123 更新时间:2023-11-28 18:37:49 27 4
gpt4 key购买 nike

我搜索了又搜索,尽管有很多关于这个问题的主题,但我找不到任何相关的内容来解决我的问题。如果有人可以看一下:

我正在使用 xcode 4.6

我在 int retVal 的 main.m 文件中收到错误

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

我的 ReaderSampleViewController.h 文件如下所示:

@interface ReaderSampleViewController
: UIViewController
// ADD: delegate protocol
< ZBarReaderDelegate >
{
UIImageView *resultImage;
UITextView *resultText;

}
@property (nonatomic, retain) IBOutlet UIImageView *resultImage;
@property (nonatomic, retain) IBOutlet UITextView *resultText;
- (IBAction) scanButtonTapped;
@end

ReaderSampleViewController.m 文件如下所示:

#import "ReaderSampleViewController.h"

@implementation ReaderSampleViewController

@synthesize resultImage, resultText;

- (IBAction) scanButtonTapped
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;

ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here

// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];

// present and release the controller
[self presentViewController: reader animated:NO completion:nil];
[reader release];
}

- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// ADD: get the decode results
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;

// EXAMPLE: do something useful with the barcode data
resultText.text = symbol.data;
// QR CODE TO THE WEBSITE
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)




//----------- STYLE AND AUTO SIZE THE WEB VIEW

float widthScreen, heightScreen; //xScreen, yScreen
if(IS_IPAD){

widthScreen = 768.0;
heightScreen = 960.0;
// xScreen = 360.0;
// yScreen = 500.0;
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"LoaderIpad.jpg"]];
self.view.backgroundColor = background;
[background release];
}else{
//CGRect webFrame = CGRectMake(0.0, 0.0, 360.0, 480.0);
widthScreen = 320.0;
heightScreen = 490.0;
// xScreen = 150.0;
// yScreen = 190.0;
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"LoaderIphone.jpg"]];
self.view.backgroundColor = background;
[background release];
}

CGRect webFrame = CGRectMake(0.0, 0.0, widthScreen, heightScreen);



UIWebView *webView= [[UIWebView alloc] initWithFrame:webFrame];
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
webView.scalesPageToFit = NO;
webView.autoresizesSubviews = YES;

[webView setBackgroundColor:[UIColor clearColor]];
//[webView setOpaque:NO];



//--------- GET THE URL
NSString *urlAddress= @"";
urlAddress =[urlAddress stringByAppendingString:resultText.text];
NSURL *url= [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj= [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[self.view addSubview:webView];
[webView release];

// EXAMPLE: do something useful with the barcode image
resultImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
//resultImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];


// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissViewControllerAnimated:NO completion:nil];
}

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orient
{
return(YES);
}


- (void) dealloc {
self.resultImage = nil;
self.resultText = nil;
[super dealloc];
}

@end

if else cgRect 维度之前工作正常,但是我可能不小心删除了一些东西或在某处放置了一个逗号,导致此错误并导致应用程序在加载时暂停。下面是它返回的错误:

2013-04-03 10:57:35.928 P&H Scanner[269:907] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ReaderSampleViewController 0x21073bc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key delegate.'
*** First throw call stack:
(0x3346e3e7 0x3b169963 0x3346e0d5 0x33cdc7d9 0x33cd8543 0x333f48a5 0x35419e7d 0x354196ff 0x35312079 0x3529c451 0x352dcd59 0x35327ef7 0xb6cb 0x352ddaa1 0x352dd625 0x352d5833 0x3527dd1f 0x3527d7ad 0x3527d1ef 0x36f955f7 0x36f95227 0x334433e7 0x3344338b 0x3344220f 0x333b523d 0x333b50c9 0x352d446d 0x352d12b9 0xb605 0x3b596b20)
libc++abi.dylib: terminate called throwing an exception
(lldb)

抱歉,我是应用程序开发的新手,因此试图解决不同的错误并苦苦挣扎。任何建议都会很棒

最佳答案

我学到的一个小技巧是在整个应用程序上有一个异常断点,所以每当你遇到一个你不认识的错误(比如与 UIApplicationMain 相关的错误)时,至少你可以粗略地知道代码在哪里休息。这可以为您提供需要从哪里开始的线索。

为此,您需要转到断点导航器 (Cmd+6),按左下角的小加号图标,选择“添加异常断点”,最后按完成。

关于ios - UIApplicationMain 错误上的 SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15784300/

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