We were having issues with our app not rotating but that problem has been solved. We now need to force our views into protrait mode.
The best scenario would be to define a subclass of our UITabBarController and then override supportedInterfaceOrientations with a portrait mask.
I can't seem to figure out how to properly subclass our UITabBarController. Can someone help?
Right click on project and choose to create a new objective-c Class and then write UITabBarController in subclass of text box. Done.
I have implemented custom tab bar controllers in a couple of projects.
#import <UIKit/UIKit.h>
#interface CustomTabBarController : UITabBarController<UITabBarControllerDelegate>
{
}
#end
You can make it like any other Objective-C class.
One very interesting way of using tab bar controller I found, was having a custom view over tab bar with buttons. You can customize your tab bar with any size or shape of tabs and you can write action on those custom tabs to change the tab for the tab barcontroller.
Related
I want to make custom tab bar. And I'm using framework of KittenYang
Here is everything is very beautiful, animated but I don't know how to add View Controller for showing. Thanks for any helps)
You do not need to add an integrated ViewControllerclass to your project, what you need to do instead is to add TabbarMenu class instance to your desired UIViewController subclass and add it as a subview to UIViewController's view.
I want to add UIView below UINavigation bar on each screen. I don't want to add it on every viewcontroller explicitly. I want to add a view in parent class so that the rest of the views in every viewcontroller starts below the view that I added below UINavigationBar. Currently, I have added a view in parent class but it appears over the views in child classes. Any solution?
Here it is i got one very nice helpful github project for show a custom message view under thenavigation bar here is link TSMessages
Make your custom UIView in xib and use inheritance concept. Create a BaseViewController and all other view controller should be subclass of your BaseViewController. Load your custom UIView in BaseViewController it will be there all other subclasses
I have some static cells that I want to display, so I have a UITableViewController. There is also a NavigationBar in this scene that contains some buttons at the top. The setup looks like this:
If I had a UIViewController that contained a UITableView in it, the setup would look like:
So, the question is:
Why does the Navigation Bar have to be embedded inside the UITableView when using a UITableViewController? (I have tried putting it elsewhere but IB won't let me)
I know that UITableView is a subclass of UIView, but is it OK that the top level element in the hierarchy is not a View (but a TableView)?
Thanks.
You shouldn't be placing your UINavigationBar in your UITableView. You should be putting your UITableViewController in a UINavigationController, because that will provide a UINavigationBar for you.
So if you select your UITableViewController in the storyboard, you can choose Embed In -> Navigation Controller from the Editor menu. This would be the proper way to do it.
There are two ways to use a UINavigationBar in iOS:
Embedded inside a UINavigationController (recommended)
As a standalone object
For your particular situation, I'd recommend that you put your UITableViewController as the rootViewController of a UINavigationController. That way you automatically get a navigation bar which you can customize according to your needs. In a typical user experience, when you tap some of your table view rows a new view controller will be pushed onto the navigation stack, so you'll probably end up needing a navigation controller anyway.
What if you decide to use a navigation bar as a standalone object? This is perfectly fine, you can use it inside a view hierarchy as an ordinary UIView, but you'll need to create another object that implements the UINavigationBarDelegate protocol and set it as the delegate property of your navigation bar. If you use a UINavigationController the delegate is already set and configured for you. You also need to add/remove navigation items (instances of UINavigationItem) to your navigation bar by using the pushNavigationItem:animated: and popNavigationItemAnimated: methods.
And about your question on the view hierarchy, you can use a UITableView anywhere a UIView is required. The only caveat is that a UITableView is a view hierarchy on its own and that may restrict your layout a little bit.
The way a UITableViewController works, is its root view is a UITableView. So there is no way to put the UINavigationBar anywhere other than in the UITableView.
I tend never to use a UITableViewController as it doesn't really give you much.
If you particularly want to use the UITableViewController, I don't believe that there is any real problem in having the navigation bar within the table view. You just need to make sure that you set the contentInset on the table view such that the navigation bar doesn't block the content. Though it seems a bit backward to do it this way.
My recommendation would be to just use a normal UIViewController with a navigation bar and a table view.
If you actually need functional navigation, you need to put your UITableViewController within a UINavigationController.
Hope this helps :)
Let me know if anything is still unclear.
I was wondering if there is a way to create a navigationBar like the one in this photo:
http://s2.postimage.org/ewem26czd/foto.jpg
and there is a way to customize its background?
It's fairly easy to customize a UINavigationBar. Simply create a subclass of it, and in the XIB where you find the UINavigationController, use the inspector on the right to change the class of the navigation controller's navigation bar to your subclass.
I am following a post here showing how to add a custom center tab bar item.
What's the best way of adding a custom centre button to a tab bar?
My only question is where should the code be put? I am using storyboards and right now I have it placed in viewwillappear for my default view that is shown. Should this go in a more generic or global area?
Create a subclass of the UITabBarController, say MyTabBarController.
In the storyboard, drag the standard UITabBarController into the scene, and change its class type to MyTabBarController.
In the MyTabBarController, insert the code within its viewDidLoad method.
If you put it within the viewwillappear method, it will be added multiple times since the viewwillappear will be called every time the tabbarcontroller is displayed.