简体   繁体   中英

UITabbar and UITableView

Hi I'm writing a iOS app with a UITableView and UITabBar. as below,

在此处输入图片说明

I'm adding the tab bar programatically and it sits on a part of my UITableView. So I can't see the last couple of table cells.

How can I fix this?

Thank you.

You have to change the frame of your tableView. In portrait orientation you should decrease it's height, in landscape mode you should deal with it's width.

This code is just a sample, it wasn't tested and may need minor improvements, but it shows an idea:

-(void) viewDidLayoutSubviews
{
    if(UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation))
    {
        CGRect r = self.tableView.frame;
        r.size.height-=49;
        self.tableView.frame = r;
    }else
    {
        CGRect r = self.tableView.frame;
        r.origin.x += 49;
        r.size.width-=49;
        self.tableView.frame = r;
    }
}

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