I tried to search but I can't find the right answer for me.
I tried to set a PromptText in the navigationBar but it does not work.
No matter where i put this line of Code
self.navigationController.navigationBar.topItem.prompt = #"MyTitle";
It does not work. I put it in the Child and RootViewController. The effect is that the RootView Controller has a prompt but not the ChildViewController.
Can anybody help me, please?
I don't know what you're trying to do exactly. But you shouldn't just change the topItem. Instead, change the view controller's navigation item like this:
self.navigationItem.prompt = #"MyTitle";
Depending on when it is called, it might not have the effect you expect because it depends on what topItem is at that time. Instead, set the prompt from each view controller's navigationItem.prompt.
Related
So what I am really doing is... I have a login page, when proper login session took place, Its navigating to another view. It contains Tab bar. So what I did is, I made a separate class for customizing 'UITabbarController'. And now I see a white screen on the top and below is the view of that class.
Can anybody help me out?
Are you subclassing UITTabBarController? It is not something you would normally want to do.
A better option is to create your second viewcontroller and add a normal UITabBarController onto that viewcontroller's view.
I am having the following problem while adding a subview to navigation controller. I even have tried to modify the Y location of frame before and after adding the subview but not effective.
Also tried to put a status bar on the child view but nothing is working.
Many Thanks.
You have a problem with a fullScreen IB checkbox or a fullscreen property set programmaticaly. Don't you call somewhere something like viewController.setStatusBarVisible = NO. Check it, I had the same problem.
EDIT : Does those questions / anwers help ?
iPhone - ModalViewController not raising to top of the screen
iPhone - displaying NavigationBar on a fullscreen modalView makes it go down with transparent space on top
Thank you very much everyone of you. I don't know what was the issue but instead of adding subview now I am using pushViewController and I am pushing the viewcontroller to the parent navigation controller. This solved the issue.
Thank you all of you once again.
I have this MonoTouch related question, but I think Objective/C programmers can help as well.
I have TabBarController with some tabs. I want my home viewController (which is added to tabBar) to appear without tabBar.
I thought the way to do it was to set HidesBottomBarWhenPushed of that controller to true.
homePage = new HomePageController();
homePage.HidesBottomBarWhenPushed = true;
homePage.TabBarItem = new UITabBarItem("Home", new UIImage("Images/Icons/home.png"), 0);
However, it seems that this works only in case of using TabBar with NavigationController, i.e. in case we actually push controllers.
I wonder if there is a way to do it just for simple viewControllers contained in tabBarController.
You can try to set the hidden property of the tab bar to YES. (or true in MonoTouch)
I found out that, in fact, you cannot cover tabBar area of tabBarController. You can set hidden property, just like Moshe said, or you can play with opacity as well but can't cover it with anything.
But there's a great alternate solution. You can use modal view, which always has higher index than regular controllers. Therefore, it will cover everything.
homePageContent.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
homePageContent.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
this.PresentModalViewController(homePageContent, false);
base.ViewWillAppear (animated);
Right now, I am setting the title in the viewDidLoad of the root view of the tab, which only changes when I click on the tab. I want this to be set before I select the tab. I tried something like:
[[self.parentViewController.tabBarController.tabBar.items objectAtIndex:2] title] = #"string";
in the first view that loads in another tab, but there is clearly something wrong since I get a left operand error.
What is the correct way to achieve what I am trying to do?
[[self.parentViewController.tabBarController.tabBar.items objectAtIndex:2] title] = #"string";
The syntax is slightly off here. You probably wanted something like:
[[self.parentViewController.tabBarController.tabBar.items objectAtIndex:2].title = #"string";
However, that won't work, since there is no title property to set. In fact, there's no way I can see to change a UITabBarItem's title once it's been initialized. You'll have to use UITabBar's setItems:animated: method to set the entire group of items at once. But it won't be fun.
I bet this would be an Apple HIG violation, which is why there's no easy way to do it with the current API. Rethink your design and ask yourself why you want to change the names of the tabs, which will confuse your users.
Try setting the title in awakeFromNib instead of viewDidLoad. The view for a view controller is not actually loaded until you need the view, and the tab bar controller by default doesn't access the view of a view controller until you actually select it (which is why you saw the title change when you selected the tab).
Since the nib is creating the view controller to start with (assuming you have built your tab bar controller in IB) awakeFromNib will be called as soon as the view controller has been built, before the tab bar controller can ask what the title is.
I have a UIViewController that is pushed onto a UINavigationController and is currently displayed. When I go to start some asynchronous task inside the view controller, I can set hidesBackButton on self.navigationItem to YES, and the back button is hidden correctly.
As soon as the task is finished, and I set hidesBackButton back to NO (on the UI thread, I might add, I've made sure of this), nothing happens. The back button remains hidden.
Has anyone seen this before? What drives me especially crazy is that in my application (the same application), in a different UINavigationController hierarchy, the exact same code works correctly!
Are you calling hidesBackButton = NO from a thread? All UI operations should be done on the main thread, otherwise they won't have any effect.
i have not been able to replicate your problem on my machine. however, i faced a similar issue with tableviews even when i was updating my ui on the main thread. but calling setNeedsDisplay fixed that issue.
Can you try this and see if this works:
[self.navigationController.navigationBar setNeedsDisplay];
I guess this should work, you need to do the same, BUT ON THE NAVIGATIONBAR instead. please let me know if this worked - as i cannot test my solution because i never get this problem :-)
Have you tried forcing the view to refresh by calling setNeedsDisplay?
Maybe the OS is not picking up the changes instantly and you need to force it.
Have you tried using the setHidesBackButton:animated: method instead? Perhaps that has a slightly different behavior.
In my case I simply had to give a title to the view, as in:
self.navigationItem.title = #"Menu";
Marinus
I have had a similar issue recently. I tried literally everything I found in SO and other forums- nothing worked.
In my case there was a modally shown UINavigationController with a simple root controller which would push one of two view controllers (A and B) on top of the controller stack when the button A or B was pressed, respectively. Controller B was the one which was not supposed to show the back button. But still, sometimes it did, sometimes it didn't.
After hours of debugging, I managed to track it down. Controller A was a UITableViewController. Each time I selected a cell in this controller, the delegate would pop Controller A off the stack. BUT. I made use of a UISearchDisplayController as well. Turned out that popping the view while the search controller was still active messed up something in the navigation controller that made it impossible to hide the back button in Controller B afterwards (well, it eventually stayed hidden between viewDidLoad and viewDidAppear: but then it always turned visible).
So the solution (rather workaround) was adding this line to where Controller A was dismissed:
controllerA.searchDisplayController.active = NO;
// ...
// [self.navigationController popViewControllerAnimated:YES];
Hope this spares someone a couple of hours.