iOS8中的UITableView崩溃

时间:2014-11-10 05:48:46

标签: ios objective-c uitableview ios7 ios8

我创建了一个带有自定义单元格的表视图。我将该表视图放在viewController上,并且每当需要时我都会呈现viewController。它在iOS6,iOS7中运行良好。来到iOS8它正在崩溃并显示错误消息,并且在某些时候它正在崩溃而没有显示任何错误消息只显示EXC_BADACCESS:

-[DropDownViewTableViewCell tableView:heightForHeaderInSection:]: unrecognized selector sent to instance 

以下是整个控制台错误消息。

2014-11-10 11:09:41.067 BML[1029:26620] -[DropDownViewTableViewCell       tableView:heightForHeaderInSection:]: unrecognized selector sent to instance 0x7ccb05e0
2014-11-10 11:09:41.075 BML[1029:26620] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DropDownViewTableViewCell tableView:heightForHeaderInSection:]: unrecognized selector sent to instance 0x7ccb05e0'
*** First throw call stack:
(
0   CoreFoundation                      0x0431c946 __exceptionPreprocess + 182
1   libobjc.A.dylib                     0x03fa1a97 objc_exception_throw + 44
2   CoreFoundation                      0x043245c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3   CoreFoundation                      0x0426d3e7 ___forwarding___ + 1047
4   CoreFoundation                      0x0426cfae _CF_forwarding_prep_0 + 14
5   UIKit                               0x02a95449 -[UITableView _delegateWantsHeaderForSection:] + 370
6   UIKit                               0x02c54935 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 169
7   UIKit                               0x02c5b59c -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 302
8   UIKit                               0x02c5b6c5 -[UITableViewRowData heightForTable] + 68
9   UIKit                               0x02a6c98c -[UITableView _updateContentSize] + 395
10  UIKit                               0x02a8f4a7 -[UITableView didMoveToWindow] + 76
11  UIKit                               0x029fe5b9 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1703
12  UIKit                               0x02a113e1 -[UIScrollView _didMoveFromWindow:toWindow:] + 65
13  UIKit                               0x029fe23f -[UIView(Internal) _didMoveFromWindow:toWindow:] + 813
14  UIKit                               0x029fe23f -[UIView(Internal) _didMoveFromWindow:toWindow:] + 813
15  UIKit                               0x029fe23f -[UIView(Internal) _didMoveFromWindow:toWindow:] + 813
16  UIKit                               0x029fe23f -[UIView(Internal) _didMoveFromWindow:toWindow:] + 813
17  UIKit                               0x029fe23f -[UIView(Internal) _didMoveFromWindow:toWindow:] + 813
18  UIKit                               0x029fe23f -[UIView(Internal) _didMoveFromWindow:toWindow:] + 813
19  UIKit                               0x029f5517 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 154
20  UIKit                               0x029f5475 -[UIView(Hierarchy) _postMovedFromSuperview:] + 458
21  UIKit                               0x02a00f0d -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2018
22  UIKit                               0x029f386e -[UIView(Hierarchy) addSubview:] + 56
23  UIKit                               0x02aa3b58 -[UITransitionView transition:fromView:toView:removeFromView:] + 1576
24  UIKit                               0x0320826d -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] + 3551
25  UIKit                               0x02aa91ad __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 2343
26  UIKit                               0x02adc7ab __40+[UIViewController _scheduleTransition:]_block_invoke + 18
27  UIKit                               0x029a20ce ___afterCACommitHandler_block_invoke + 15
28  UIKit                               0x029a2079 _applyBlockToCFArrayCopiedToStack + 415
29  UIKit                               0x029a1e8e _afterCACommitHandler + 545
30  CoreFoundation                      0x0423f9de __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
31  CoreFoundation                      0x0423f920 __CFRunLoopDoObservers + 400
32  CoreFoundation                      0x0423535a __CFRunLoopRun + 1226
33  CoreFoundation                      0x04234bcb CFRunLoopRunSpecific + 443
34  CoreFoundation                      0x042349fb CFRunLoopRunInMode + 123
35  GraphicsServices                    0x0684724f GSEventRunModal + 192
36  GraphicsServices                    0x0684708c GSEventRun + 104
37  UIKit                               0x029788b6 UIApplicationMain + 1526
38  BML                                 0x0014bc2d main + 141
39  libdyld.dylib                       0x048b4ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

DropDownViewTableViewCell.h

#import <UIKit/UIKit.h>

@interface DropDownViewTableViewCell : UITableViewCell
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, retain) IBOutlet UIImageView *imageVie;

@end

DropDownViewTableViewCell.m

#import "DropDownViewTableViewCell.h"

@implementation DropDownViewTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
 if (self) {
    // Initialization code
 }
 return self;
}
- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

  // Configure the view for the selected state
}

@end

TableViewImplementation

 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
 {
   return 35;
 }
 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
 {
   return 1;
 }
 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
 {
   return 1;
 }

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
 // Return the number of rows in the section.
   return [self.poiDataArray count];
 }
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
    DropDownViewTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
  if (!cell)
  {
       if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
      {
          [tableView registerNib:[UINib nibWithNibName:@"DropDownView_iPhone" bundle:nil] forCellReuseIdentifier:@"myCell"];
         cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
      }
      else
      {
         [tableView registerNib:[UINib nibWithNibName:@"DropDownView_iPad" bundle:nil] forCellReuseIdentifier:@"myCell"];
         cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
         CGRect frame;

         frame =cell.label.frame;
         frame.size.width +=50;
         cell.label.frame=frame;
      }
  }
  return cell;

 }

0 个答案:

没有答案