Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Starting a table view from the bottom of the screen

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 228
    Comment on it

    Hello Readers,

    In case you want to start a table view from the bottom of the screen rather than the top of the screen, you may call the following method from the delegate method as follows:

    - (void)updateCellInset {
        NSInteger numRows=[self tableView:_tableView numberOfRowsInSection:0];
        CGFloat contentInsetTop=_tableView.bounds.size.height;
        for (int i=0;i<numRows;i++) {
        contentInsetTop-=[self tableView:&#95;tableView heightForRowAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
            if (contentInsetTop<=0) {
                contentInsetTop=0;
                break;
            }
        }
        _tableView.contentInset = UIEdgeInsetsMake(contentInsetTop, 0, 0, 0);
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
        // Configure the cell...
         [self updateCellInset];
         return cell;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        return value;
    } 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: