Domanda

I have a static table view that i set up in story board, targeting iPhone 5. The table view takes up the full screen for iPhone 5 (Height = 568) and the TableView has 11 cells. When this is run on the iPhone 3.5 inch only 9 of the cells show. Is there a way using autolayouts or another to have the cell heights adjust so that all 11 cells show on the screen regardless of the screen size. The cells were created statically in Storyboard. I want to be able to resize the cells based on screen size.

Don't hesitate to ask if something is unclear.

È stato utile?

Soluzione

use this code to set based on the your cell height required.

     - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
        {

int intheight=(int )[UIScreen mainScreen].bounds.size.height;

        if(intheight==568)
            return 100;
        else
            return 80;



        }

Altri suggerimenti

You can try to add this to your controller

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [UIScreen mainScreen].bounds.size.height/11;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top