Custom UIView covering UITabBar on iPhone but not iPad

半城伤御伤魂 提交于 2019-12-11 04:43:18

问题


I'm creating a custom uiView that covers the window. It acts kinda like a decoy uiview in a navigation controller. So I had to do it this way to cover the navigation bar.... long story...

Here is how it gets setup.

self.searchPopDown.frame = CGRectMake(0, 20, self.navigationController.view.frame.size.width, self.navigationController.view.frame.size.height-20);

    self.searchPopDown.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

The 20 is to compensate for the status bar.

Then I simply add the view as a subview to the app window.

//this will add the view ontop of a modalViewController and support rotation!
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}

if ([[[window subviews] objectAtIndex:0] isKindOfClass:[SVProgressHUD class]]){
    //There is a chance that the window will be the SVProgressHUD in this case we need to get the main window.

    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
    [[[window subviews] objectAtIndex:0] addSubview:self.searchPopDown];

All of this works great and dandy. However I've noticed something strange. On the iPhone this view will end up being resized to cover the UITabBar at the bottom of my app. But on an iPad it gets resized correctly to compensate for the UITabBar. Any ideas why?

Thanks

=================

Here are some screenshots describing the issue. This is what it looks like when the view loads with the fake view onto of everything. The view shows up (as far as the user is concerned just the view and the buttons on the navbar have changed slightly. When you have searched this fake view disappears revealing the real view below with the search results. ON the ipad the fake view doesn't cover the tab bar. Why doesn't it do this on the iphone also?

==========

edit 2 Another weird thing. I'm generating log messages to get what the height of the navigation controller is. It changing by 49 depending on if I display normally or present as a modal view and there is no tab bar.

So the log says 431 should be the correct height. I go into interface builder and setup a simple pink view that's measured at 431 and it looks great :) However when I manually set the size to 431 it doesn't work. I have to set the size to 298 to get this to work correctly ... weird...

See the pink bar? It is literally 431 tall... and the log says that's what my view is.. but it's not :/

============

edit:3

I have traced this to the imagebackground with the bubble logo resizing incorrectly...


回答1:


I had to check "clip subview" on the parent view that the imageview was in... fixed the problem...



来源:https://stackoverflow.com/questions/12645234/custom-uiview-covering-uitabbar-on-iphone-but-not-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!