简体   繁体   中英

change width of a UItableview custom cell

Am using custom cell in my tableview with background image. when the orientation changes cell size not getting changed, I need to change the custom cell size automatically when orientation change.How can i achieve this ?

You can set tableview frame programatically on delegate -

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

You can use

[tableView setFrame:[self.view.frame]];

Enjoy

Just make sure to return YES in shouldAutorotateToInterfaceOrientation method, no need to set frame if your class is UITableViewController .

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM