Adding a UIToolBar above a UITabBar - Logic Issue - iphone

I need to know the logic of how to write this code.
This is my problem.
When a user taps a button, I need to show a UIToolBar (with a few buttons on it) on the view. This toolBar should appear ONLY above the UITabBarcontroller.
The view is a UIScrollView, so if I hardcode the position of the UIToolBar, it will be displayed in the wrong position each time the user scrolls (Hope you understand what I am saying).
I did the following. I hard coded the position of the UIToolBar (so it will place above the tab bar), and added it to the Window. This sounds like a good solution as the windows size will not change at all instance.
But, I don't want to add this to a Window. So is there any other way I could solve this problem?

I would add an additional UIView to the window so that it acts as a container for both the UIScrollView and UIToolbar. Then resize the scrollview so that it falls short of the toolbar.
You should be thinking of this as layers of views

Related

Adding UIButton to UIImageView within UIScrollView on Swift

I am writing an application for an event my organization is hosting using Swift. I have an image with the floor layout and want to add buttons to select locations (such as bathrooms, entrances, exits, emergency sections, etc) so that people can click them and information about the location pops up.
I currently have an imageview with the floor layout within a scrollview to allow the user to zoom in and out of the image. When I try to add buttons to the scrollview they don't stay relative to the image when zooming in and out, nor do their size change. I have tried adding constraints on to make the location stay the same when zooming in and out.
It also won't let me relocate the button on the storyboard to be a subview of the imageview. Looking up similar solutions says to add the button programmatically as a subview of the imageview but then it'd be really hard to put the 100+ buttons in the right location. Any suggestions as to how to go about this?
you have no other choice instead of adding by code.. because from code you can add as subview of image view , whereas Storyboard wont add buttons as subviews of imageView, but it will add buttons as subview of Scroll View

iphone - Shrink image on scroll away in UIScrollView

So I have a UIScrollView in my app's menu. I have paging enabled and each page contains a button and an image. I would like to add a little animation where these start to shrink as they disappear off the screen (when the user scrolls to the next page).
I know I could do this by creating a property for each button and image and then manually changing the frame size in the scrollViewDidScroll method.
Does anyone have a more elegant solution so that I dont have to hard code each one in? It is possible that there's a predefined attribute for this or something?
Is each "page" in the scrollview actually a view or view controller? Whatever it is, hopefully it's an instance of some class, and thus reusable. Add a method to the custom view/view controller that uses the UIView animateWithDuration: methods to make the button and image shrink. Call that method when you determine that the scroll view has moved enough.

UISegmentedControl inside UIToolbar does have wrong height for Lanfscape

Somehow the Segmented Control does not get the proper height when the iPhone is in Landscape.
It is already bad enough when rotating the simulator that the toolbar at the bottom doesn't get thinner height, but when navigating back to the previous screen and then in again, the toolbar does get the propper height, but the segmented control extends above it, and even looks much bigger.
Is the is bug in the simulator or am i doing something wrong?
After digging around another day, I found where it all went wrong!
When dealing with UINavigationControllers, DO NOT drag in a UIToolbar at all! UINavigationController comes with two bars, a top-bar for the Navigation Controller and a bottom-bar for the ToolBar - that latter one is hidden by default.
In any newly added ViewControllers, there will be a toolbar that can be populated from the IB. However, if it is not a UIBarButton, there are some issues. To use a stepper, on/off-switch or a segmented control, drag it first to the Navigation bar, and then in the left column navigator of IB, drag it to the toolbar.
This solved all the problems mentioned before

How to set a custom UIToolBar always in the front and top of the application?

I've been stuck with this for a while now. Im trying to put a custom toolbar always in the front of my iPad application (in the front of other views), however im not sure how to tell the UIApplicationDelegate to establish it as the parent view.
I tried using a navigation controller but i need it stuck always in the top and i couldn't get rid of the transition animation when changing views.
Any help will be appreciated. Thanks!
You have to set that custom toolbar in main window or add that toolbar programmatically as a subview in your window,
and after that in all your child view controller set view size,
For example if your toolbar has height of 50px that the X position of your all child view must be start with 50px.
This approach is works for me,
Hope it will help you also.

UIPopoverController in application window

I am creating a UIPopoverController from the application delegate and I want to center it on the window, how ca I do that?
You can specify the rectangle that it is anchored to when you display it. Just specify an rectangle and direction that guarantees it will be displayed in the position you want.
It does sound like you may be doing something that would be best done by presenting a custom UIView as a new subview instead of using a popover. The popover will always have the little arrow coming off the side.