【发布时间】:2015-09-15 06:05:23
【问题描述】:
`我正在 AdHoc 测试一个应用程序,它可以让你登录到 apache 服务器,拍照,然后将它们作为 jpeg 缩略图上传到 UIScrollView。从那里您可以点击拇指以全屏查看。该应用程序在 iPad 上完美运行,但是当我点击拇指在 iPhone 4 上全屏查看它时,应用程序崩溃/冻结,编译器用
突出显示以下代码行 线程 1:EXC_BAD_ACCESS(代码=1,地址=0xf6c04478) //当应用程序在 iPhone 4 上冻结时,代码编译器会同时高亮显示 [api commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"stream", @"command", IdPhoto,@"IdPhoto", nil] onCompletion:^(NSDictionary *json) { ***编辑*** 在调试器显示 (lldb) 并输入“bt”后,显示的是: * 线程 #1: tid = 0x5a399, 0x3931598e libobjc.A.dylib`lookUpImpOrForward + 46, queue = 'com.apple.main-thread', 停止原因 = EXC_BAD_ACCESS (code=1, address=0xf6c04478) 帧#0:0x3931598e libobjc.A.dylib`lookUpImpOrForward + 46 帧#1:0x39315956 libobjc.A.dylib`_class_lookupMethodAndLoadCache3 + 34 帧#2:0x3931a8b8 libobjc.A.dylib`_objc_msgSend_uncached + 24 帧#3:0x2ea9b5a8 CoreFoundation`+[__NSDictionaryM __new:::::] + 536 帧#4:0x2ea9e2f0 CoreFoundation`-[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 240 帧#5:0x2eaa2dcc CoreFoundation`+[NSDictionary dictionaryWithObjectsAndKeys:] + 372 * 帧 #6: 0x0002c07c faunna`-[StreamPhotoScreen viewDidLoad](self=0x17f86c70, _cmd=0x319d0af3) + 200 at StreamPhotoScreen.m:8 帧 #7: 0x313814aa UIKit`-[UIViewController loadViewIfRequired] + 518 帧 #8: 0x31381268 UIKit`-[UIViewController 视图] + 24 帧 #9: 0x3150d36a UIKit`-[UINavigationController _startCustomTransition:] + 634 第 10 帧:0x3142ad62 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 418 帧 #11: 0x3142ab6c UIKit`-[UINavigationController __viewWillLayoutSubviews] + 44 框架 #12: 0x3142ab04 UIKit`-[UILayoutContainerView layoutSubviews] + 184 帧 #13: 0x3137cd58 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 380 帧 #14: 0x30ffa62a QuartzCore`-[CALayer layoutSublayers] + 142 帧 #15: 0x30ff5e3a QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 350 帧 #16: 0x30ff5ccc QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16 帧 #17:0x30ff56de QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 230 帧 #18: 0x30ff54ee QuartzCore`CA::Transaction::commit() + 314 帧 #19: 0x30fef21c QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56 帧 #20:0x2eb2b254 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20 帧 #21: 0x2eb28bf8 CoreFoundation`__CFRunLoopDoObservers + 284 帧 #22: 0x2eb28f3a CoreFoundation`__CFRunLoopRun + 730 帧 #23:0x2ea93ebe CoreFoundation`CFRunLoopRunSpecific + 522 帧 #24:0x2ea93ca2 CoreFoundation`CFRunLoopRunInMode + 106 帧 #25:0x33999662 GraphicsServices`GSEventRunModal + 138 帧 #26:0x313e014c UIKit`UIApplicationMain + 1136 帧 #27: 0x0003f6dc faunna`main(argc=1, argv=0x27de1d14) + 108 at main.m:14 (lldb)这是完整的streamphotoscreen...
#import "StreamPhotoScreen.h"
#import "API.h"
@implementation StreamPhotoScreen
@synthesize IdPhoto;
-(void)viewDidLoad {
API* api = [API sharedInstance];
//load the caption of the selected photo
[api commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"stream", @"command", IdPhoto,@"IdPhoto", nil] onCompletion:^(NSDictionary *json) {
//show the text in the label
NSArray* list = [json objectForKey:@"result"];
NSDictionary* photo = [list objectAtIndex:0];
lblTitle.text = [photo objectForKey:@"title"];
}];
//load the big size photo
NSURL* imageURL = [api urlForImageWithId:IdPhoto isThumb:NO];
[photoView setImageWithURL: imageURL];
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
@end
为什么应用程序崩溃了?会不会是 iPhone 本身?
【问题讨论】:
-
NSMutableDictionary创建成功了吗?确定NSMutableDictionary是否在单独的语句和中间变量中创建可能更容易。 -
Xcode 控制台面板中没有错误信息吗?
-
只是 '(lldb) ' 这就是调试区域显示的全部内容
-
什么是
Thread 1. EXC_BAD_ACCESS(code=1,address=ox28),我该如何解决? -
什么是线程回溯,在lldb中输入bt查看。您将需要提供更多信息。什么是
api,什么是IdPhoto?
标签: ios objective-c iphone xcode uiscrollview