Custom popup view in Swift (Interface Builder) - swift

Is there any way I can show a custom popup in the middle of the screen (over the current content) with buttons and a textfield and anything else I may need, entirely in interface builder?
If this isn't possible, then I don't mind doing it programatically.
I am guessing you create a custom view with the content but I am not sure how I show that view when a button is clicked and bring it up over the current view controller.
Thanks!

I would create a View and a Viewcontroller for it- set the alpha of the view to zero so its invisible - then but a nice picture as background for the custom popuop on it ( as background for the popup) on this i would put the buttons and the text label. Voilà - costum pop-up is ready to present with a segue (choose type over the current view controller).

Related

How can I load into a different view in a popover?

I have some code that opens a popover window that displays some text. This is done by an action segue rather than actual code in a storyboard. Is there any way, that I can load into a different view by pressing a button on the popover view and have it load into the next view? I've tried using another action segue, but it puts a popover into my current popover over the button that I press. Thanks!
This kind of thing can't be done with just storyboards; some code will be necessary.
Here's how I would do this: instead of trying to use two separate popovers, use one popover with kind of a "nested" setup. The popover's content view controller would contain, say, a Page1ViewController and a Page2ViewController. When first displayed, the main controller would install page 1's view. You could maybe wire the action from page 1's button directly to the main controller, but I recommend that you use delegation for this. Create a protocol that's something like Page1ViewControllerDelegate and adopt the protocol in your main controller, then in the delegate method for page1ControllerRequestTransition(_:) or whatever you choose, just grab the page 1 view out and swap the page 2 view in. You can even have the two views be different sizes; the popover will automatically adjust itself.
Oh, and don't forget to disable translatesAutoresizingMaskIntoConstraints and add appropriate constraints to fix the four sides of each page's view.

creating a class that pops up an advertisement image

I have a tab bar controller and some nav controllers containing view controllers. In those view controllers I want to be able to have a timed banner that will animate up from the bottom of the view.
I started making a subclass of UIViewController with the images, but when I add it to my viewControlers it renders anything beneath it not clickable.
What is the best way of achieving this ad pop up and have it be reusable in all my viewControllers?
Make sure the main view of this ad popup is not of zero width or height - banners from many ad networks will actually be displayed if you add them to such a view, but won't be clickable.
Also make sure the ad view is in front (bringSubviewToFront:) and, if you have a tab bar, try adding it to the main app's window, rather then to the current view. Tab bar can play tricks with Action Sheets (basically some buttons will be unclickable) which are solved by adding the Action Sheet to the main window. This may help with your popup ad views, too.

Switchable subview in window for iphone app

I've been looking everywhere but can't seem to find any examples/tutorials for my situation (not sure how to google it..)
So i have a window where a portion of it should be static (buttons and such) and there is a dynamic part (bottom leftish) that should change subviews.
So what i'm looking for is a way so that clicking the buttons in the static area will change the dynamic area to a view of my choice. I have no idea how to do this using the IB, but doing it programatically seems the only way. Any suggestions(I do not want to use a tab bar controller)?
Oh, and is there a benefit to making views and such programatically vs through the IB?
Thanks!
You can also achieve it programatically. Just create another viewcontroller class (as many as u want). In the loadView method of it create a UIView in the coordinates where u want to add the subview in the current view. Now create an instance of this viewcontroller class in the currentview controller and add it as a subview. You will get the subview at the desired location.If u want to change it dynamically create as many views and then add them to the array and change them whenever the button is clicked.
Hope this helps.
You should perform the switch in your view controller. The static buttons can have their actions hooked up to that controller (in IB), which can have an outlet (in IB) to the subviews and perform the swap.
As for when you should use IB, see this question.
You can do it from interface builder as well. You just need to take viewController from interface builder drag-n-drop to main window. assign IBAction to all buttons to add different viewController's view to main window just make their frame some smaller.
if u want to change or views by click on button then u chose segmentcontrol switch. and cod for each segment like as when click on segment 0 then open first sub view and when click on segment1 then open second sub view. And make by default unselected so that ur static view will appear initially lunching of view.

Toolbar at the bottom not showing

I used the xcode4 xib file to design the following UI:
View
Table View
Toolbar
Bar Button Item
Segmented Control
Bar Button Item
Segmented Control
On the design sheet, both Table View and Toolbar show up; but when I run the app in simulator, the toolbar is not showing up.
I tried to make the table view invisible (as a test) and to bring the toolbar to the front. Still the toolbar does not show.
Do you have any idea what I might be doing wrong, and what I should try next? Do I need to do init for the toolbar in the .m file?
Thanks much!
Lu
Have you set the the toolbarHidden property of your UINavigationControllerto NO ? You have to explicitly do this to show the toolbar as it is defaulty set to YES. If this isn't the issue, we need to see some code, especially your toolbar initialization and etc.

Remove UISearchBar on tableView click

I have a UISearchBar which is subviewed by another view when a button is pressed. When it loads, it looks like the following (minus the red scribbles):
I would like to have the UISearchBar view be removed from the parent view controller when the tableView (the area with red scribbles) is clicked and is empty (no search has been made yet). I'm having a difficult time figuring out the best way to do this.
I have tried to put a transparent button in that section and add it as a subview to the search bar. However the button is underneath the tabl view area, so when the table view is clicked, the search bar loses focus and the uibutton is only then accessible.
Does anyone know how I can remove the search bar from the parent view controller when the empty table view below it is clicked?
Thanks.
To bring the transparent button up and make it catch all touched first, use [button.parentView bringSubViewToFront:button].
Another approach could be to catch the search bar losing focus (since you say you see that happening), by putting
– (void)searchBarTextDidEndEditing:(UISearchBar*)searchBar
in the search bar delegate, and handling it from there.