zoukankan      html  css  js  c++  java
  • 通过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中连接问题。
     
  • 相关阅读:
    GitCam一款Gif动画制作软件
    IniParse解析类
    一个网页设计师应该考虑的9件事
    Backit轻松为您的网站创建备份
    [翻译]Web开发牛人访谈:你们都在用什么?
    简单文件服务器
    一个网站访问速度测试工具
    GS运维常用工具及文档
    Oracle快速收集AWR的方案
    Oracle调整内存参后报ORA-00844和ORA-00851
  • 原文地址:https://www.cnblogs.com/hanyutong/p/4475661.html
Copyright © 2011-2022 走看看