2011-11-25 51 views
0

我的應用程序崩潰ans顯示以下在控制檯中。如何刪除這個異常?ViewController長度無法識別的選擇器發送到iPhone中的實例

2011-11-25 17:47:56.519 ShowroomLocator[1482:707] -[ShowroomLocatorViewController length]: unrecognized selector sent to instance 0x164860 
2011-11-25 17:47:56.541 ShowroomLocator[1482:707] *** Terminating app due to  uncaught exception 'NSInvalidArgumentException', reason: '- [ShowroomLocatorViewController length]: unrecognized selector sent to instance 0x164860' 
    *** Call stack at first throw: 
(
0 CoreFoundation      0x308aa64f __exceptionPreprocess + 114 
1 libobjc.A.dylib      0x3400bc5d objc_exception_throw + 24 
2 CoreFoundation      0x308ae1bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102 
3 CoreFoundation      0x308ad649 ___forwarding___ + 508 
4 CoreFoundation      0x30824180 _CF_forwarding_prep_0 + 48 
5 UIKit        0x35dcfed1 - [UITableView(UITableViewInternal) _delegateWantsHeaderForSection:] + 228 
6 UIKit        0x35dcf2db -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 78 
7 UIKit        0x35dcf225 -[UITableViewRowData numberOfRows] + 72 
8 UIKit        0x35dcec73 -[UITableView noteNumberOfRowsChanged] + 82 
9 UIKit        0x35dce7f7 -[UITableView reloadData] + 582 
10 HettichShowroomLocator    0x00003487 - [ShowroomLocatorViewController viewWillAppear:] + 50 
11 UIKit        0x35dbf1d9 -[UIViewController viewWillMoveToWindow:] + 64 
12 UIKit        0x35d9e179 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 132 
13 UIKit        0x35d83a59 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 228 
14 UIKit        0x35d8396b -[UIView(Hierarchy) addSubview:] + 22 
15 UIKit        0x35db335f -[UIWindow addRootViewControllerViewIfPossible] + 202 
16 UIKit        0x35daf333 -[UIWindow _setHidden:forced:] + 182 
17 UIKit        0x35db328f -[UIWindow _orderFrontWithoutMakingKey] + 18 
18 UIKit        0x35dc1c61 -[UIWindow makeKeyAndVisible] + 16 
19 ShowroomLocator    0x0000285b - [ShowroomLocatorAppDelegate application:didFinishLaunchingWithOptions:] + 162 
20 UIKit        0x35db3821 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772 
21 UIKit        0x35dadb65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272 
22 UIKit        0x35d827d7 -[UIApplication handleEvent:withNewEvent:] + 1114 
23 UIKit        0x35d82215 -[UIApplication sendEvent:] + 44 
24 UIKit        0x35d81c53 _UIApplicationHandleEvent + 5090 
25 GraphicsServices     0x35a56e77 PurpleEventCallback + 666 
26 CoreFoundation      0x30881a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26 
27 CoreFoundation      0x3088383f __CFRunLoopDoSource1 + 166 
28 CoreFoundation      0x3088460d __CFRunLoopRun + 520 
29 CoreFoundation      0x30814ec3 CFRunLoopRunSpecific + 230 
30 CoreFoundation      0x30814dcb CFRunLoopRunInMode + 58 
31 UIKit        0x35dacd49 -[UIApplication _run] + 372 
32 UIKit        0x35daa807 UIApplicationMain + 670 
33 ShowroomLocator    0x0000278b main + 70 
34 ShowroomLocator    0x00002740 start + 40 
) 
terminate called after throwing an instance of 'NSException' 
Program received signal: 「SIGABRT」. 
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.2 (8H7)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found). 
(gdb) 

與_tableview1我的應用程序添加SearchDisplayController後開始崩潰。 我在同一個控制器類中有兩個tableview。普萊斯提出好的建議來處理這個......

多的tableview編碼編輯:

- (void)viewDidLoad { 
appDelegate = (ShowroomLocatorAppDelegate *)[[UIApplication sharedApplication] delegate]; 

NSArray *items = [[NSArray alloc] initWithObjects: 
        @"Sydney Airport (SYD), Mascot NSW 2020, Australia", 
        @"Sydney NSW, Australia'", 
        @"Smithfield NSW 2164, Australia", 
        @"Smithfield SA 5114, Australia", 
        @"Smithfield QLD 4878, Australia", 
        nil]; 

self.allItems = items; 
[items release]; 
    self._tableView1.scrollEnabled = YES; 
_tableView1.hidden = YES; 
_tableView.hidden = YES; 
[self._tableView reloadData]; 

self._tableView.rowHeight = 80.0; 
[ self.view addSubview:_tableView] ; 
_tableView.delegate = self; 
_tableView.dataSource = self; 
_tableView1.delegate = self; 
_tableView1.dataSource = self; 
} 
- (void)viewWillAppear:(BOOL)animated 
{ 
[self._tableView reloadData]; 
[self._tableView1 reloadData]; } 


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
if(tableView ==_tableView && tableView ==_tableView1 ) 
{ 
    return 1; 
} 
} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 
if(tableView ==_tableView) 
{ 
if(section == 0) 
    return [NSString stringWithFormat:NSLocalizedString(@"ShowRooms[%d]", @"Showroom format"), [appDelegate.markers count]]; 

} 
} 



// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableview numberOfRowsInSection:(NSInteger)section { 

if(tableview ==_tableView) 
{ 
return [appDelegate.markers count]; 
} 
if(tableview ==_tableView1) 
{ NSInteger rows = 0; 

if ([_tableView1 
    isEqual:self.searchDisplayController.searchResultsTableView]){ 
    rows = [self.searchResults count]; 
} 
else{ 
    rows = [self.allItems count]; 
} 

return rows; 
} 
    } 

在我_tableview Web服務數據得到填補,並與地址_tableview1陣列數據得到填補..... 上述錯誤是在添加_tableview1未來.....

+0

你的代碼崩潰在你的viewController的'length'方法上(你的代碼中是否存在'length'方法?)。如果它確實存在,你能顯示一些代碼嗎?如果它不存在於你的視圖控制器中,找出你在哪裏以及如何調用假長度方法。我認爲這與桌面視圖無關。 –

+0

哎呀,它是[ShowroomLocatorViewController length]。 –

+0

向我們展示您的lenght

回答

0

我懷疑,在viewWillAppear,你做的reloadData指定self而非self.tableView

+0

我沒有得到你......我做了這個[self._tableView reloadData]; –

+0

好的,然後在別的地方你傳遞一個ShowroomLocatorViewController,你應該通過它,例如一個NSString。 (或者,您可能正在傳遞一個NSString或其他長度實現的對象,這個對象沒有被正確保留,並被另一個對象替換。) –

相關問題