zoukankan      html  css  js  c++  java
  • iPhone4s 7.0.3-4 TableView 数据越界 解决方案

    在实现一个TableView时需要实现两个代理方法<UITableViewDataSource,UITableViewDelegate>实现

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

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

      正常情况下系统会默认先执行- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;方法,再执行- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath,这样是没有问题的。

       但是在有些没有升级的到iOS7.1的用户来说,例如4s 用户只升到了7.0.3或7.0.4,当你改变TableView的Frame的时候,系统不会执行- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; 方法,导致数组越界。

       所以为了保持代码的健壮性,应该在dataArray改变时,先执行TableView的Reload方法,再去改变TableView的Frame。就不会出现数组越界的问题!

  • 相关阅读:
    Linux JDK安装
    Redis集群搭建
    Struts2 中添加 Servlet
    js小技巧:数组去重
    修改Request 中的数据
    JAVA 图形界面开发基础详解
    JAVA 类和对象基础知识详解
    Java 类的继承详解
    C++ 大学课堂知识点总结
    数据库简单练习 建表+select
  • 原文地址:https://www.cnblogs.com/i0ject/p/4091426.html
Copyright © 2011-2022 走看看