I have a view with a UITabBar and the navigation bar is initially hidden. When I press the next tab I want the nav bar to be shown, but when I do this using setNavigationBarHidden: the view gets resized, and the tabbar is pushed out of the screen. How do I setup the views to where they won't get resized? Or get resized properly?
You will have to check your autoresizingMasks. You can adjust them programmatically or via IB. Autosizing is available in the Size Inspector on the right.
You will mostly have to change the tab bar's mask to fix it to bottom and left. Rest of the subviews will have to be handled as needed.
[self.navigationController setNavigationBarHidden:NO animated:NO];
or
after that
set urview frame to exactly for 44reduce(which is navingation bar height) from height.
Related
I have a Vaadin 8 application with several views.
public class ViewName extends Panel implements View {
There is a VerticalLayout as main layout in the panel.
public ViewName() {
setSizeFull();
VerticalLayout mainLayout = new VerticalLayout();
setContent(mainLayout);
Then I have many different layouts (HorizontalLayout, GridLayout) or Components such as Label being added as components to the mainLayout. For the HorizontalLayouts I often do the following to use the full width of the screen:
hLayout.setWidth("100%");
I have a lot of icons, grids etc. Everything is OK as long as I don't resize the window.
When I resize the window to a small size I get a mess (icons, text etc. on top of each other) and no horizontal scrollbar. (However, the grids get horizontal scrollbars.) I have tried many things to fix this. If I add
mainLayout.setSizeFull();
or
mainLayout.setWidth("100%");
I have a mess on the big screen already. I also tried the CSS for the mainLayout as described here. I get several scrollbars but none for the window itself!
The only component that resizes correctly is a Label added to the mainLayout, e.g.:
Label title = new Label("Some text",ContentMode.HTML);
title.setWidth(100, Unit.PERCENTAGE);
mainLayout.addComponent(title);
mainLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER);
I also noticed that anything in a GridLayout seems to stay in place after resizing but is not vissible since I have no scrollbar. However, icons in a HorizontalLayout get on top of each other.
What is wrong? Please, I need a general instruction on which layout I should use as main layout for my view panel, how to size the components and how to get ONE horizontal scrollbar for the main window if necessary.
The problem is that you are setting the width of your mainLayout to the width of your view. This means, that your mainLayouts width will never be bigger than your views width. So no scroll bar will appear.
According to the information you posted, changing your mainLayouts width to undefined should fix the problem.
mainLayout.setWidth("-1px");
I've a UIWebView. Everything is fine if I don't add navigation controller. But If I add, a dark grey layer on the top of my uiwebview appears. I don't understand what is wrong, I'm just adding a uiwebview and haven't written a line of code about sizing or layout.
http://i.stack.imgur.com/KRTuU.png
This is probably because your navigation bar's translucent property is set to YES. Set it to NO and the dark grey background will go away.
You can hide that navigation bar by adding this:
self.navigationController?.isNavigationBarHidden = true
to the view controller's ViewDidLoad()
I have a UITabBar app that I build using xib in IB. In my view on IB, it has the bottom bar. In the following image, the bottom bar is just under the UIToolBar. It is under the toolbar, because I have no option to put it on top of the bar.
When I run the app, the toolbar appears in the middle of the screen as shown here. How can I fix that? I want it to be between the tab bar and the web view.
You need to set some Auto Layout constraints or an autoresizing mask in Interface Builder to tell your toolbar how to position itself.
Update: Assuming I understand what you're trying to do, try these constraints:
Web view: 0 distance from top and sides, (height of tab bar + toolbar) from bottom.
Toolbar: 0 distance from sides, default (or some constant) height, (height of tab bar) from bottom.
Tab bar: 0 distance from sides, default (or some constant) height, zero distance from bottom.
I have a view withing a panel with this styleCLass applied.
.scrollPanel { width:100%; height: 375px; overflow: auto;}
That panel is nested with an extension pages Application control.
I want both the height and the width of the panel set so the scroll bars of the panel appear and the browsers scroll bars are NOT activated.
This CSS works perfectly for width. I can resize my browser window and the width of the panel adjusts as needed and the browser horizontal scroll bars never come on.
But if I try 100% for height, it does not work the same. If I resize for height then the vertical scroll bars for the browser appear.
Also it would be nice to have the height of the panel always equal to the height of the available screen. With 100%, the height is very small if the view is collapsed. The height expands when the view expands. I would like for it always to be the same size percentage wise to the available height of the browser.
P.S. The set size I have of 375 works perfectly with the exception it does not resize with the browser.
Is there any way to do this?
You would need to register a window.onresize event that fetches the actual size of the window and modifies the panel accordingly, e.g. by setting its height with a style.
So the best way would be to create a method that modifies the size of your panel according to the windows size, respecting a minimum and a maximum value. Once that function is finished, you would just need to register it to the onresize event that gets fired when anything has changed the viewports display dimensions (read, a real resize or something that has enabled the windows scrollbars).
In the perfect world you would debounce/throttle the execution of this method to maybe at most every 100ms to avoid excessive CPU load during a window resize with the mouse and a window border, because depending on the browser, that event gets fired on every single pixel the mouse has moved during such a resize - which is fairly often and may lead to a slower UI response.
I have a UIScrollView (managed by a view controller) which I am using both full screen and as a subview. The full screen version works fine - the subview does not.
The subview is positioned so that it takes up about the bottom half of the screen, with a small - 20 pixels or so - margin at the bottom.
Initially it displays in the correct position but overwrites the bottom margin - even though the scrollview's frame is set to leave the margin.
When I scroll the view up by dragging it, the whole view moves upwards and obscures the top of the window. The frame stops moving when it hits the navigation bar at the top and starts scrolling like a normal scrollview. If I scroll it enough it eventually reveals the margin at the bottom of the screen.
I am at a loss to know what to do - I've tried every spring combination I can think of. I'm now looking at subview clipping.
Images below. The first shows the scrollview on initial page load, positioned correctly aside from lower margin overwrite. The scroll view has a white background.
The second image shows it scrolled up toward the top:
The third image shows it scrolled all the way up to the top - note that the lower margin has become visible.
I'm not 100% sure on this one, but worthy the shot: my guess is you're likely not setting the Bounds property correctly on your table.
To solve this issue, the easiest way would be to set myscrollview.clipsToBounds = true.
Something is definitely wrong here. I think what happens is that you are adding the same instance of scrollview as a subview on itself. So basically what you are left with, is one instance alone. Anything you add to the "subview", is basically added on the superview, since it is the same object.
For example, this is what I think you are doing in the view controller:
//...
private UIScrollView myScrollView;
public override void ViewDidLoad()
{
this.myScrollView = new UIScrollView();
this.View = this.myScrollView;
this.View.AddSubview(this.mySrcollView); // same instance
this.myScrollView.AddSubview(aUIButton); // "aUIButton" will be added in View also, since it is the same object
}
If this is the case, it is wrong. I suggest not changing the controller's view at all. If you want to have a controller that has a fullscreen UIScrollView, just create it and add it as a subview, making sure the AutoSizesSubviews property to true.
That's my understanding at least.