• 通过xib加载视图到控制器时 出现的各种错误


    1.Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]

    原因:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
    返回的为空。
    我这里的问题是在此方法中加载自定义cell时出得问题,加载xib未成功。
    解决:如问题2.

    2.关于xcode TableView使用Nib文件出现Assertion

    原因:我在使用tableViewCell的nib文件时 出现此问题

    解决:自定义cell  xib方式

     

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        

        static NSString *CellIdentifier = @"MyCell";

        BOOL nibsRegistered = NO;

        if (!nibsRegistered) {

            UINib *nib = [UINib nibWithNibName:NSStringFromClass([MyCell class]) bundle:nil];

            [tableView registerNib:nib forCellReuseIdentifier:CellIdentifier];

            nibsRegistered = YES;

        }

        MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

            return cell;

    }

     
    3.怎样加载xib
     
      1、self.view = [[[NSBundle mainBundle] loadNibName:@"mianview"  owner:self  options:nil] lastObject];
     
      2、UIViewController *controller = [[UIViewController alloc] initWithNibName:@"mainview" bundle:nil];
          self.view = controller.view;
     
    4.自定义的View  customer  选择view时,imageView连线报错this class is not key value coding-compliant for the key head.'
     解决:view对应customer选择相应的View,File's owner对应customer选择相应的Controller类
     
    5.  Terminating app due to uncaught exception 'NSUnknownKeyException'
    原因:我这里在xib中有多余的控件 ,删掉就可以了。一般此问题 都是xib中连接问题。
     
  • 相关阅读:
    基于jackson的kotlin json字符串对比器
    python之一mac安装HTMLTestRunner.py
    python之插件安装
    饿了么三面:让你怀疑人生的Spring Boot夺命连环40问
    网易三面:说说你对MySQL事务四大隔离的理解
    京东Java岗:来自面试官的夺命连环56问,你怀疑人生了吗?
    QPushButton
    宏相关使用
    C++类构造析构基础
    P8261 [CTS2022] 袜子 解题报告
  • 原文地址:https://www.cnblogs.com/hanyutong/p/4475661.html
Copyright © 2020-2023  润新知