Dynamic UIView in UITabBaritem - iphone

Basically what I have is View with a series of UIButtons and depending on what button is pressed a View with UITabBar is displayed with a certain UITabBarItem selected. This works out fine, however what I want to do is to change the UIView within the UITabBarItem.
So for example: I have 8 buttons on the my first view. I press button 1 and UITabBarItem 2 is selected and View A is displayed, however if I press button 2 UITabBarItem 2 is selected but instead of View A it displays View B.
What exactly is happening is, if I have viewDidLoad method the code within is preloaded before I can change it dynamically. So I tried using viewWillAppear but nothing seems to happen.
Any help will be appreciated. I hope I have made my question clear enough for everyone.

try to implement the uitabbarcontroller protocol and overwrite
these methods:
– tabBarController:shouldSelectViewController:
– tabBarController:didSelectViewController:

Related

ActionSheet with SegmentControl Swift 3

Is it possible implement SegmenControl in ActionSheet (UIAlertController) How can I do this? Thanks.
Example
Just another way of achieving the required functionality without the UIActionSheet:-
In your storyboard make a new UIViewController
Add a UITableView in your newly created UIViewController
Set Presentation to Over Current Context in the attributes of your ViewController
Change the Background color of your View in your ViewController to Clear
Create a Seague from the ViewController to your newly created View controller and set it to Present Modally.
Add the constraints to your UITableView that it covers half of the screen.

How to "Dock" a UIToolbar to the bottom of the screen in UITableView?

I have a UIToolbar that I added to a UITableViewController in my Storyboard.
When this view is displayed, the toolbar will show itself directly below the last item in my UITableView. I want to "Dock" my toolbar on the bottom of the screen. I want it to display in the same place every time rather than move around depending on a variable number of table cells in my view. I need the user to be able to see all the cells as well (It can't be covering UITableView items, UITableView needs to decrease its allotted display space). How can I do this?
Edit: Using a UINavigationController to handle my views
You have a couple of options. The first and easiest of the two would be to use a UITableViewController embedded inside a UINavigationController, with the navigation controllers toolbarHidden property set to NO.
The other option is to use a UIViewController. A view controller has a UIView build in, and you can manually add and position a UITableView and a UIToolbar on it in this configuration. Both of these configurations will achieve your desired end result.

UIPopoverController on UITableViewCell

I have a UITableView cell with several UITextFields in it. When a user clicks into one of the textFields, a popover appears with some information. At first, they then had to click outside of either the textField or the popover to clear the popover before then clicking into the next textField. I therefore then added the cell's contentView to the popover controller's passThroughViews property so they can click through the different textFields in that cell at will without having to dismiss the popover controller first. However, it keeps the original popover open (which) is fine, and then opens another identical popover as well.
Is there a way I can tell if a popover is already open before sending the command to open another? I can't think of how to detect this?
If each cell controls the logic of the popover, you need to say to your custom cell to implement UIPopoverControllerDelegate protocol, set the delegate for the popover as self (the cell) and override popoverControllerDidDismissPopover like the following:
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
[self.pop dismissPopoverAnimated:YES]; // hide the popover
self.pop = nil; // release the popover, this forces to create a fresh popover each time
}
If you want you can also remove the line self.pop = nil; but remember to release it in dealloc (I suppose you are not using ARC code since you are using retainCount). As bbum suggested you should't use retainCount to check objects existence.
In addition, each UIPopoverController instance has a property called popoverVisible if you want to see if a popover is already visible or not.
OK, I did it. For others who find this question. In addition to the other answers, this is how I did it.
I made my view controller a UIPopoverControllerDelegate.
I then created an BOOL called myPopoverControllerOpen.
When I created my popover I set the BOOL to yes. Using the delegate method popoverDidDismissPopover I then set the BOOL back to NO.
I then check on the state of this BOOL before presenting the popover.

UITabBarItem and its UIViewController - a complex issue

I have a bit of complex issue with a UITabBarItem it's UIViewController. Basically I have a series of UIButtons which is a layer on top of UITabBar, if the a UIButton is selected the right UITabBarItem is selected.
The complex issue starts when I have a UIViewController that is displayed when one of the UITabBarItem is pressed this takes the whole screen and displays a series of UIButtons. Once you press a button it returns back to the UITabBarItem selected but what I want in the UIViewcontroller is to have a dynamic UIView. I can get everything else working except that because the viewDidLoad is pre-loaded within that view.
Any suggestions. Sorry if that was a mouthful!
Now that I understand what you are asking, it seems that you need the view within the fifth tab to change based on what button is pressed - you can achieve this by making a bunch of graphic buttons to fill the view, then to have the fullscreen overlay you need to have your view present the new view as a modal view controller.
[self presentModalViewController:controllerForButton1 animated:NO]
This actually doesn't have much to with tab bars, this just happens to be within a tab bar controller, and they used the fifth view to hold a big menu, because there weren't enough tabs to suit their need.

Is there any way to display the arrow button on UINavigationbar without actually pushing a controller?

As titled. I need a way to display the arrow buttom on UINavigationbar without actually pushing a controller. The reason why I can't push a controller is because I need to keep the keyboard displayed while transitioning.
So to clarify: I start with a modal view controller (where there's nothing on the top left bar) like this -
(source: iphonefaq.org)
Then transition the top bar to one that looks like this -
(source: gizmodo.com)
Sure, you can do this pretty easily. Just set the leftBarButtonItem of your self.navigationItem to be a back button.
It looks like you can do this by getting the UINavigationItem for the current screen. You can get it from the topItem property of the UINavigationBar.
Once you have the UINavigationItem that represents your current title are you should be able to experiment with the backBarButtonItem property, then call setHidesBackButton:animated: to show the back button.
You can*not* dynamically change the backbutton on the UINavigationItem instance that belongs to the UIViewController instance that is currently being displayed. The backbutton that you will see displayed is the last one that was set before the UIViewController instance (and its UINAvigationItem) was pushed.
BUT, you can show/hide the backbutton. So how about setting the correct backbutton before the UIViewController instance is pushed and hiding it (viewControllerInstance.navigationItem.hidesBackButton = YES;"). And then setting "viewControllerInstance.navigationItem.hidesBackButton = NO;" when you want to display the back button.
You can obviously dynamically change the UINavigationItems and their backbuttons on a UINavigationBar that you create yourself (i.e. one that does not belong to a UINavigationController).