UITabBarController with none selected controller - iphone

In the 3.0 version of the iPod application (and maybe in previous versions too) when the iPod application is launched after a sync the UITabBarController appears with no tab selected...
iPhone iPod loading screen
Is there any way to accomplish the same behaviour? or is this just the Default.png displayed by the iPod app at startup?

This will work when your tab bar is already loaded:
self.tabBarController.selectedViewController = nil;
In applicationDidFinishLaunching, you'll have to use something like this:
[tabBarController performSelector:#selector(setViewController:) withObject:nil afterDelay:0];

I'm not sure it's the default.png, when I launch mine the loading screen appears to be all black - and you wouldn't expect a default.png to be able to have the tab bar elements when you are allowed to re-order them as you are in the iPod app.
Perhaps if you set the UITabBarController selectedVC to nil...

That doesn't look/feel like it is done with Default.png. Looking at the docs online (under selectedViewController), you can select a view controller that isn't shown in the tab bar but still in the viewControllers array, and may be this is how it's done in the iPod/music app. So essentially make a view controller for a tab that isn't selectable from the tab bar by the user, and select that view controller programatically.

Was able to get this working by making the selection on my tab bar controller from applicationDidBecomeActive with the following code:
- (void)applicationDidBecomeActive:(UIApplication *)application {
self.tabBarController.selectedViewController = splashScreenControllerThatHasNoTab;
}

Related

Rotate only one view controller in a tabbed application

I've read to many posts but I can't find a solution.
I've a tabbed application using storyboard. All the View Controllers of that Tabbed Application must show the content in portrait orientation, but there's only one viewcontroller (which is showing a video) that I want to be in landscape mode.
EXPLANATION OF THE STORYBOARD: TabBarController -> 4x Navigation controllers -> each navigation controller points to his ViewController -> one of these view controllers have an image, when I press that image, i've done a push to another view, the view that I want to have in landscape mode because I have there a UIWebView to show a video.
I'm unable to have all the app only in portrait orientation and the viewcontroller mentioned capable to rotate in landscape mode.
My app is also supporting iOS 5, so I know there are methods deprecated and I'm getting crazy.
I believe that in Summary > iPhone / iPod Deployment info > Supported Interface Orientations > there I've to check Portrait, Landscape left and right, and then via methods, enable or disable the rotations. I'm lost.
Can you help me?
I think you should be able to do this if you push to the view as a modal. Make sure your application's PList file (under Supporting Files folder) is set to support all orientations and then simply add the code to the modal view controller to display landscape with something like this.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Let me know if you have any luck.
As i worked out for my App i advise you to use this solution.By using some conditions in the shouldAutorotateToInterfaceOrientation method orientation type we can solve this.Just try with this link will help you.
https://stackoverflow.com/questions/12021185/ios-rotate-view-only-one-view-controllers-view/15403129#1540312

Multiple Splash Screen with some Action

Here's The probem.
I have an iPhone app that needs to have 2 splash screens.
the first splashscreen will show for 1 or 2 second before it fading out and changing to the second splash screen and in the second splash screen it has [x]close button in the top right corner which similiar to windows close button.
and it has an action to close the second splash screen and go to the main window.
i already try to make it with variety of ways, but i'm not even close to the goal.
and maybe it's because i'm totally new in iphone apps development.
so guys, i really need your help..
If I interpret your request correctly, you can accomplish this by triggering a segue from your app delegate. Say, for example, that you want to do the following after app launch:
Show View A for 2 seconds
Fade to View B
Have user tap [x] close button to reveal View C
You can something similar to the following if you are using Storyboards:
Configure an initial view controller MYAViewController. Add MYBViewController. Add MYCViewController.
Then set an outgoing segue from MYAViewController to MYBViewController. Select this segue and from the Attributes inspector, give it an Identifier of AToB, set its style to Modal, set its transition to Cross Dissolve and ensure that Animates is selected.
Add another segue from MYBViewController to MYCViewController. Select this segue and configure however you want to, but give it has an identifier of BToC.
Then from your app delegate, trigger the segues programmatically.
In MYAppDelegate:
...
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self performSelector:#selector(showViewB)
withObject:nil
afterDelay:2.0]; // seconds
}
- (void)showViewB {
[self.window.rootViewController performSegueWithIdentifier:#"AToB"
sender:self.window.rootViewController];
}
...
Note that all view controller names and segue identifiers are contrived. Obviously, you would want to name these items in a way that is meaningful to your application.
Hope this helps.

iOS iPad start landscape, push VC, popVC, view has bad positioning

I start my app in landscape for iPad. A nav controller holds my tableVC I click on a cell we push a new VC onto the stack. That works fine. The problem is, when I press the standard "back" button on the nav controller, my app gets forced into portrait and my tableVC is off of the screen. I am doing no manual positioning of views. This doesn't happen if I start the app in portrait mode.
How do I fix this abnormal behavior?
Notes: There is also a tab bar present in the app if it matters.
Upon further testing, if I load the NavController in portrait (with the first view being the table view) then switch it to landscape, then select the cell, then press back, it works fine. So the problem only happens if i start the app in landscape and never turn it to portrait.
EVERY VC has shouldAutoRotate set to return YES. I have subclassed the tab bar and done the same. I am wondering if this is a bug. Perhaps the problem lies in the fact that I took existing .XIB files and their views that were created for iPhone, then copied and pasted them, then deleted the iPhone specific views and then added iPad views.
If your subclassed TabBar Controller returns yes, and ALL of your VCs return yes for shouldAutoRotate, then the problem lies within your xib files. Though your explanation makes it sound like the VC you are pushing doesn't return yes, you've stated that it does, so it must be the xib files.
In IB, try setting the default orientation of your xib views to landscape, clean - build and run.
That may provide a clue or two.
Maybe you can create a new and simple iPad application with just a tabbarcontroller a navigation controller and 2 viewcontrollers to test if the cause is or is not the recycled iPhone .XIB files.
Also you can Command+Shift+F to search in the whole project for ": UIViewController" to double check that every VC has shouldAutoRotate set to return YES, in case you have third party code in your application that has a subclass of UIViewController on it. (the search will return a list of headers files that inherits from UIViewController).
I had had similar problems with really weird behaviors that were fixed by deleting the .XIB file and made it again.
Good luck finding the problem =)

Starting an app with a Tab View and no tabs selected?

I'm developing an iPhone app with Objective-C and iOS SDK with a tab view on the bottom. I want to make the app so that when it first loads up, the tabs are on the bottom, but none of them are selected. Instead, the user is presented with a "home" view, and can select the tabs from there if he / she desires.
How would I make this work? I'm assuming it's something in the App Delegate?
Thanks!
I did this recently. Just do
[self.myTabBar setSelectedItem:nil];
Works perfectly, no tabs should be selected. Let me know if you have any problems. Also, just put that in either - (void) viewDidLoad or initWithNibName .
I think this would be something that's appropriate to fake.
I would:
Add a subview that overlays the area normally occupied by the selected tab view.
Add UITabBarControllerDelegate tabBarController:shouldSelectViewController that will hide/remove that view.
The only remaining problem is to make the actually selected tab button seem unselected until the subview is hidden.

Mimic iPod application UI

I am looking for the best approach to mimic the iPod application on the iPhone/iPod Touch. Specifically, I want to mimic what happens when the iPod player (when a track is actually played) shows up. The iPod application starts as a tabBarController with every tab holding a navigationController. However, when a track is played, the entire tabBarController is replaced by a new viewController.
What is the best approach for this kind of UI? At first, I thought the tabBarController needed to be added to a separate navigationController, but this resulted in two navigation bars (one on top of the other).
Any advice is welcome. Cheers.
Use the hidesBottomBarWhenPushed property. Your controller will stay within your existing navigation-controller hierarchy (unlike fluchtpunkt's solution), and the tab bar will automatically hide and show itself when your player controller appears and disappears.
you want to present the new viewcontroller as a modal vc.
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated