iPhone - Making a Tab Bar Transparent - cocoa-touch

How do I make a tab bar transparent in cocoa touch?

Now with iOS 5 you can change the UITabBar appearance to make only the background transparent with a simple line of code:
[[UITabBar appearance] setTintColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.2]];

Since UITabBar is a subclass of UIView, have you tried adjusting its alpha property?
Note that if you are trying to modify a tab bar associated with a UITabBarController, you should consider this warning from Apple, located in the reference for UITabBar:
Important: In iOS 3.0 and later, you
should not attempt to use the methods
and properties of this class to modify
the tab bar when it is associated with
a tab bar controller object. Modifying
the tab bar in this way results in the
throwing of an exception. Instead, any
modifications to the tab bar or its
items should occur through the tab bar
controller interface. You may still
directly modify a tab bar object that
is not associated with a tab bar
controller.

Related

Container view is expected to be populated at this point

i have a simple ios implementation. There is a tableviewcontroller embedded in a navigationcontroller and a qlviewcontroller in this implementation, navigationcontroller is embedded in a tabbarcontroller too.
Actual tab lists a lot of image files, if a cell is selected in the tableviewcontroller, a qlpreviewcontroller will be instantiated and image file will be shown. another tab shows only settings of app.
i have subclassed the qlpreviewcontroller. The instance of this subclass will be created with the following code part;
XYQLPreviewController *qlpvc = [[XYQLPreviewController alloc] init];
qlpvc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:qlpvc animated:YES];
i want to hide tabbar in the preview controller so that there is enough place to preview.
these all work very well with ios 6 and below but with ios 7 i have the following problems;
Back button of navigation bar in qlpreviewcontroller doesnt respond, its not clickable.
if i back navigate with this new cool slide transition of ios 7, ta ta my tabbar got lost, i see only a white layer at the tabbar not my cool tabbar.
i see the following log message in log screen,if i select an image file and instantiate the subclass of previewcontroller.
"Container view is expected to be populated at this point"
what a problem can it be , i have no idea.
Please help.
PS:i have only a xib file not the storyboard.
If you want to hide the tab bar, I would say your best bet is to present the preview controller as a modal instead of pushing it onto the stack. Then when the user closes it (instead of hits back), it will bring them back to the tab bar view.
[self.navigationController presentViewController:qlpvc animated:YES completion:nil];

UITabBarController "want full screen" setting

In IB for an UITabBarController, there is a setting for each view controller for each tab that called "want full screen". The book I am reading says that if you want to display your view in full screen then select that option. But you will need to have away to get back to your tab bar. Unfortunately, this book does not have any samples that use this setting. And I have tried myself but when I tapped on the tap bar the resulted view is not full screen. Any one know how to use it properly?
The wantsFullScreenLayout property of UIViewController, is used to hide the status bar and navigation bar, and place your view from the screen top instead of really making UIViewController full screen.
That is, when wantsFullScreenLayout set to YES, your origin point (0, 0) of your view controller's view will be the same point as the top left corner of status bar.
Thus, this property is usually used with translucent status bar.
#property(nonatomic, assign) BOOL wantsFullScreenLayout
For example, Photo.app in iOS uses this property to show thumbnails.

Move UITabBar to the top of a UITabBarController?

I just finished designing a application that uses a top bar that toggles between three UIViewControllers. My first thought was to use a UITabBarController, since it works very simular.
However, the tabBar is at the bottom and in my PSD, it's at the top. Is there anyway I can change it? I see in the library I can drag in a UITabBar, but I don't know how to get it to change pages from there.
Please help!
Coulton
Hope the below code helps
UITabBarController *tabC = [[UITabBarController alloc]init];
tabC.tabBar.frame = CGRectMake(0, 0, 320, 70);
NSArray *arr = [[NSArray alloc]initWithObjects:firstObj,secObj, nil];
tabC.viewControllers = arr;
[self.window addSubview:tabC.view];
Worked fine for me
I think it can be done, but you should be aware of this:
"Important: In iPhone OS 3.0 and later, you should not attempt to use the methods and properties of this class to modify the tab bar when it is associated with a tab bar controller object. Modifying the tab bar in this way results in the throwing of an exception. Instead, any modifications to the tab bar or its items should occur through the tab bar controller interface. You may still directly modify a tab bar object that is not associated with a tab bar controller."
So, in your UI (I suppose you defined it in Interface Builder), instantiate a UITabBar object (by choosing it in the IB library and dragging it to your view in IB). Choose the default position and also define the way that this tab bar autoresizes (using the size pane of the info window). Then, add an outlet to your view controller of type UITabBar, and, finally, connect the tab bar object to the tab bar outlet.
Once you have done this, in your view controller's viewDidLoad method you can customize any property of the tab bar that you want to.

UINavgationController and UITabBarController together

I am trying to create a view with a TableView in the center, NavigationBar on top, and a TabBar with 5 items. The TabBarItems will be attached to 5 different modal views. And the tableview can select an item and "navigate" to another tableview or detail view.
Following the Apple doc, I tried to create a NavigationController in a TabBarController in IB, but failed. I read all the posting regarding to this topic, and they all described a NavigationController inside one of the TabBarItem. But that is not what I want. The TabBarController and NavigationController are separate controller doing separate thing in the same view.
So I start wondering maybe it is a design issue. I should just use a NavigationController and add the TabBar as objects and not controller in the view.
Am I going the right track or is there a better way to combine NavigationController and TabBarController in IB to do the job that I want. Am I making sense?
If the tab bar is actually being used as a tab bar, it sounds like you want 5 navigation controllers, one for each tab.
If the tab bar is being used as a toolbar to hold buttons that bring up modal view controllers, push views onto the navigation controller, or other actions besides what a tab bar is intended for, use a UIToolbar instead. UINavigationController actually has toolbar support built in, just set its toolbarHidden property to NO and set the toolbarItems property on each view controller that can go inside the navigation controller to an array of appropriate UIBarButtonItems.

Setting Toolbar Items of UINavigationController

In iPhone OS 3.0, you can set the toolbar items of a UINavigationController using the setToolbarItems:animated: method. However, this requires you pass in an array of UIToolbarItems. While I could programmatically create these toolbar items, I'd rather create them in Interface Builder if possible.
With this in mind, I have created a UIToolbar in "MyGreatViewController.xib" and have populated it with the wanted toolbar items. Then, in "MyGreatViewController.m", I get the items from the toolbar and pass them to setToolbarItems:animated::
- (void)viewDidLoad {
[super viewDidLoad];
[self setToolbarItems: [toolbar items]];
}
...where toolbar is an IBOutlet referring to the UIToolbar.
Is this a good approach? Is there a better way to accomplish this? Should I just create the items programmatically?
I don't know if this is documented anywhere, but I've found that in Interface Builder, if you enable the navigation controller's toolbar, you can drag bar items to your view controller, and they will automagically show up in the navigation controller's toolbar.
For example, here's what we can do (using Xcode 3.2 on Snow Leopard):
File->New Project.... Choose Navigation-based Application and create the project.
Open MainWindow.xib in Interface Builder.
Select the Navigation Controller, and in the Attributes inspector, check the "Shows Toolbar" box. This will cause a Toolbar object to appear.
Drag a Bar Button Item from the Library to the toolbar. It will appear in the toolbar. If you check the hierarchy in the NIB, you'll see that this new item is a child of the RootViewController.
It seems that any Bar Button Items added as children of the navigation item will show up in the navigation bar, and any Bar Button Items added as children of the view controller will show up in the toolbar.
(I stumbled on this by accident. If anyone can find documentation for this behavior, or any additional info, I'd like to hear about it.)
It's a perfectly acceptable way of doing it, but do bear in mind that loading xib files is quite expensive on the iPhone, and it may well be faster to create the toolbar items programatically in your viewDidLoad method.