Viewcontroller长度无法识别的选择器发送到iphone中的实例

时间:2011-11-25 12:42:40

标签: iphone uiviewcontroller crash

我的应用程序崩溃,在控制台中显示以下内容。如何删除此异常???

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网络服务数据中获取填充和_tableview1数组数据,地址获取填充..... 上面的错误正在添加_tableview1 .....

1 个答案:

答案 0 :(得分:0)

我怀疑,在viewWillAppear,您执行了reloadData指定self而不是self.tableView