2015-01-12 1 views
-3

Я сделал ячейку uitableview, чтобы показывать комментарии, и эта ячейка содержит новое представление таблицы для отображения подкомпонентов. обычно он работает нормально, но иногда он внезапно падает, сообщая о непризнанном селекторе NSUITableViewCellAccessibilityElement. Я потратил много времени, но не могу это исправить. Я даже не знаю, когда произойдет этот крах. Может кто-нибудь ответить на мой вопрос, THX !!!custom uifyview crash reports NSuitableviewcellAccessbilityElement superview] непризнанный селектор к экземпляру

#import "HMCommentCell.h" 
#import "HMHttpUtil.h" 
#import "HMCommonUtil.h" 
#import "HMSubcommentCell.h" 
static NSString *cellForSubcomment = @"cellForSubcomment"; 
static NSString *subcommentCellnib = @"HMSubcommentCell"; 

@interface HMCommentCell()<UITableViewDataSource, UITableViewDelegate,  HMSubcommentCellDelegate> 


@end 
@implementation HMCommentCell 

- (void)awakeFromNib { 
    // Initialization code 
    [self setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    [HMCommonUtil setupTitleTextView:_titleTextView]; 
    [HMCommonUtil setupTextView:_contentTextView]; 

    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, 1)]; 
     headerView.backgroundColor = [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:100.0/100.0]; 

     [_subCommentsView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 
     _subCommentsView.scrollEnabled = NO; 
     _subCommentsView.delegate = self; 
     _subCommentsView.dataSource = self; 
     _subCommentsView.tableHeaderView = headerView; 
     _subCommentsView.tableFooterView = nil; 

     [_subCommentsView registerNib:[UINib nibWithNibName:subcommentCellnib bundle:nil] forCellReuseIdentifier:cellForSubcomment]; 


    } 

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

     // Configure the view for the selected state 
    } 

    - (void)setSingleComment:(HMCommentEntity *)singleComment{ 
     _singleComment = singleComment; 
     //[_subCommentsView reloadData]; 
    } 

    - (void)SetupWithCommentEntity:(HMCommentEntity *)commentEntity{ 
     _userAvatarImageView.image = [UIImage imageNamed:@"MembersIcon"]; 
     if(commentEntity.creator.is_post_creator){ 
      _userAvatarImageView.backgroundColor = [UIColor colorWithRed:254.0/255.0 green:177.0/255.0 blue:45.0/255.0 alpha:100.0/100.0]; 
      [_authorLable setHidden:NO]; 
     }else{ 
      _userAvatarImageView.backgroundColor = [UIColor clearColor]; 
      [_authorLable setHidden:YES]; 
     } 
     [HMHttpUtil asyncLoadImage:commentEntity.creator.avatar 
          success:^(UIImage *image) { 
           _userAvatarImageView.image = image; 
          } fail:^(NSError *error) { 
           NSLog(@"读取用户头像失败 %@", [error description]); 

          }]; 
     [HMHttpUtil asyncLoadImage:commentEntity.image_info.image_url 
          success:^(UIImage *image) { 
           _slideImageView.image = image; 
          } fail:^(NSError *error) { 
           NSLog(@"读取评论图片失败 %@", [error description]); 
          }]; 
     //NSLog(@"the reply_to_id of this comment is %@", commentEntity.reply_to_id); 
     _titleTextView.text = commentEntity.commentCellTitle; 
     _contentTextView.text = commentEntity.content; 
     _timeLable.text = commentEntity.time; 
     _singleComment = commentEntity; 
     if([_singleComment.children count] == 0){ 
      _subCommentsView.hidden = YES; 
     }else{ 
      _subCommentsView.hidden = NO; 
      [self AdjustHeightOfContent:commentEntity]; 
      [self AdjustHeightOfSubcomments:commentEntity]; 
     } 
     //[_replyButton setTitle:@"Reply" forState:UIControlStateNormal]; 

     [_subCommentsView reloadData]; 

    } 

    #pragma mark - tableview datasource 
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 
     return 1; 
    } 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
     return [_singleComment.children count] > 0? [_singleComment.children count]:0; 
    } 

    - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
     HMSubcommentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellForSubcomment]; 
     cell.commentEntity = [_singleComment.children objectAtIndex:indexPath.row]; 
     cell.delegate = self; 
     return cell; 
    } 

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 
     return ((HMCommentEntity*)[_singleComment.children objectAtIndex:indexPath.row]).contentHeight; 
    } 


    #pragma mark - adjust the cell layout 
    - (void)AdjustHeightOfContent:(HMCommentEntity*)commentEntity{ 
     CGRect contentFrame = _contentTextView.frame; 
     contentFrame.size.height = commentEntity.contentHeight; 
     [_contentTextView setFrame:contentFrame]; 
    } 

    - (void)AdjustHeightOfSubcomments:(HMCommentEntity*)commentEntity{ 
     if(commentEntity.subCommentHeight > 0){ 
      CGRect subtableFrame = _subCommentsView.frame; 
      float gap = commentEntity.subCommentHeight - subtableFrame.size.height; 
      subtableFrame.size.height = commentEntity.subCommentHeight; 
      subtableFrame.origin.y = subtableFrame.origin.y - gap; 
      [_subCommentsView setFrame:subtableFrame]; 
     } 
    } 

    #pragma mark - reply function 
    - (IBAction)ReplyFromCell:(id)sender { 
     //[_delegate onReplyWithCommentEntity:_singleComment replyid:_singleComment.reply_to_id mark:_singleComment.mark]; 
     [self ArouseReplyFunction:_singleComment]; 
     // NSLog(@"Reply button reacts"); 
    } 

    - (IBAction)IntoCommenterInfo:(id)sender { 
    } 

    - (IBAction)IntoBigImage:(id)sender { 
     if(_bigImageBoard){ 
      [_bigImageBoard ShowBigImageUsingANewVC:_singleComment.image_info.image_big_url]; 
     } 
    } 

    - (void)SubcommentCellOnReplyWithCommentEntity:(HMCommentEntity *)commentEntity{ 
     [self ArouseReplyFunction:commentEntity]; 
    } 

    - (void)ArouseReplyFunction:(HMCommentEntity*)commentEntity{ 
     if(_delegate != nil){ 
      [_delegate CommentCellOnReplyWithCommentEntity:commentEntity commentIndex:_indexrow]; 
     }else{ 
      NSLog(@"commentcell delegate 为空"); 
     } 
    } 
    @end 
+0

Не могли бы вы предоставить свой код? – CephBirk

+1

Показать код, в котором вы вызываете супервизор - то есть строку, в которой генерируется исключение – Paulw11

+0

@ Paulw11 Я никогда не вызываю супервизор в своем коде, и исключение выбрасывается из чего-то вроде памяти. Так странно – Rabiiit

ответ

0

Я не знаю, что здесь происходит. Но я уверен, что проблема вызвана представлением таблицы в ячейке. Я не знаю, найдет ли кто-нибудь этот вопрос. Я должен сказать, что встраивание прокручиваемого контроллера в прокручиваемое является опасным. Я адаптировал нормальный путь.

Смежные вопросы