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。就不会出现数组越界的问题!

  • 相关阅读:
    第二天续
    使用git提交本地仓库每次需要输入账号密码的问题解决
    第二天
    开启远程之路
    第一天
    第一步了解并且安装配置
    6
    Algorithms
    Algorithms
    Algorithms
  • 原文地址:https://www.cnblogs.com/i0ject/p/4091426.html
Copyright © 2011-2022 走看看