iPhone GUI like the build-in iPod application - objective-c

Need a GUI with many tabs (TabBarController and UITabBar) and one fullscreen view, e.g. a view with player in the native iPod app. It's possible to show last from any tab.
Currently use last iPhone SDK 3.0.
I tried many approaches, e.g. create Utility and put TabBarController on the flipside, but it throw an exception, because of there is no "plain" UIView on the NIB, except several in a TabBarController.

You would probably keep a pointer to the tab bar controller and a separate full-screen view controller in your app delegate. You'd have to manually implement switching out the tab controller's view and the full-screen controller's view.

Ok. My investigation is completed.
The best is to create TabBars application and show main independent view as modal using
[self presentModalViewController:viewController animated:YES];
and [self dismissModalViewControllerAnimated:YES];
Thanks for the answers.

Related

Need clarity on if I'm switching View Controllers correctly

I'm making an ipad app which has 11 view controllers in storyboard, one of which is a master view that contains buttons to control which of the other view controllers is displayed as its subview.
Does anybody know for sure if it's ok to use UIViewControllers as subviews of other UIViewControllers, with hard evidence from apple or another source? It has been working flawlessly for me using this method so far:
int nextPage = (method to determine nextPage based on button pressed);
[currentView.view removeFromSuperview];
currentView = [self.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:#"page%i",nextPage]];
[self.view insertSubview:currentView.view atIndex:0];
[currentView.view setFrame:CGRectMake(0, 0, 1024, 768)];
Some people online say that if you are using ios5 or later, it's ok, but others say "NO NEVER DO THIS!!!" even if it's ios5. Others say to use container views, but in every tutorial I've seen to use a container view you just end up inserting the view controller as a subview to the main view anyway using this after you've inserted the child view:
[self.view addSubview:self.currentView];
I am not using a Navigation Controller because they have limited customizability and I do not want any stock tab bars or navigation bars, just all custom buttons.
Thanks in advance!
Yes of course, it's how UINavigationController works and how UITabBarController works. Interface Builder will event set it up for you with a container view.
see Creating Custom Container View Controllers
The takeaway is it's important to handle childViewControllers. This can get a bit tricky, but is important for notifications to propagate correctly.

Adding a view to a NavigationController that isn't pushed to the stack

I've added a UIToolbar to a NavigationController because I wanted to use the realtime blurring capabilities of the toolbar. I also wanted to customize the size - which means I can't use the toolbar built in to the NavigationController. I had to create my own and add it as a subview.
The problem is that I only want it on one particular view in my navigation stack. When I push subsequent views, the toolbar stays on the screen. I want it to be covered by the view pushed on the stack as the view slide-animates itself in to place.
How can I get it to do that without writing a custom animation?
[self presentViewController:MyController animated:YES completion:nil];
Presents a view like a modal. Exactly what I needed.

splash screen with loading indicator using storyboard

I'm working on an app for a blog site, and I'm trying to keep the Default.png launch image up with a spinning indicator while I load the initial headlines into the tableview.
I set up a viewcontroller/view in my storyboard with the launch image and indicator.
I then have the following in the viewDidLoad: method of my navigationController's rootview
[self.navigationController presentModalViewController:[self.storyboard instantiateViewControllerWithIdentifier:#"SplashLoader"] animated:NO];
And once the headlines are loaded I use:
[self.navigationController dismissModalViewControllerAnimated:NO];
Am I way off base here? Or is this the right way to be doing this?
I've seen people doing something like this in app delegate, but that was before storyboards... If I'm supposed to be doing this in the app delegate then how do I instantiate the view controller out of the storyboard?
Thanks,
Any advice or suggestions would be appreciated.
The way I've done it is to make a UIImageView using the Default.png image. In viewWillAppear: I add it to the view controller's view property. In viewDidAppear: I use a UIView animation to fade out the image view by setting its alpha to 0. Upon completion of the animation, viewDidAppear: removes the image view from its superview and releases it (sets it to nil).
You have to keep a record of how many time viewWillAppear: and viewDidAppear: have been called because you only want this animation to happen when the app launches. Also, you have to think about which image to use to create the image view. If this is an iPhone app, you want to use Default.png. If it's an iPad app, you want to use Default-Portrait~ipad.png or Default-Landscape~ipad.png, depending on the orientation of the device when the app launches.
I'm not sure how you would accomplish the same effect in the app delegate. That seems like an unnecessarily complicated approach to me.

How to switch from one view to another in iPhone?

I am a beginner in objective-c. Can anyone please tell me how can I switch from one view to another in an iPhone application.
View Programming Guide for iOS
iPhone View Switching Tuturial
How To Switch Views using Multiple Viewcontrollers (Method 1)
Switching Views with Animation
How to animate View swap on simple View iPhone App?
switch between uiviews with buttons and not uinavigation controllers
Switch between UIViewControllers using UISegmentedControl
There are 3 main controllers that can switch views for you:
UINavigationController
Here you push and pop views in a chain.
There will be a navigation bar on top which lets you navigate back to where you came from.
UITabbarController
Here all the views will be represented by tabs at the bottom of the screen.
You can switch back and forward between them by clicking them in the tabbar.
UIViewController
There is a method in UIViewController wich lets you "present" other viewcontrollers. It's called presentModalViewController:animated:
You will have to do your own navigation back to the parent by using dismissViewControllerAnimated:
You can also do your own switching with variations of addSubView: or view.hidden or similar, but I would recommend those 3 to begin with.

Can I use a UINavigationController as the detail view of a UISplitViewController?

I'm running into a problem with an iPad app where I would like to have UINavigationControllers in both of the views within a UISplitView. I've looked through other similar questions here, but most link to a tutorial online that doesn't completely solve the problem. Here's a 2-minute walkthrough to re-create the problem I'm having:
Create a New Project in XCode, starting from the Split View-based Application template.
Add the following NSLog statement as the first line within the DetailViewController's willHideViewController method:
NSLog(#"toolbar: %#", toolbar);
If you run the application now, the log will show that the DetailViewController's toolbar is alive and well. Now...
Open MainWindow.xib and expand the SplitViewController.
Drag a Navigation Controller from the library on top of the DetailViewController.
Expand the new Navigation Controller and change the class of the UIViewController within to a DetailViewController.
Ctrl-drag from the SplitViewController to the DetailViewController and assign it as the delegate.
Save MainWindow.xib and run the app again.
At this point, the detail view has a navigation bar and an empty toolbar. If you view the logs, you should find that the toolbar is null. Why is this? Am I missing some sort of connection in Interface Builder? Is the navigation bar the problem for some reason?
Unlike the tutorial at http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/, I would like to keep both the navigation bar and the toolbar (preferably with the toolbar at the top when in portrait and not visible when in landscape), so that I still have a functional "Back" button when the iPad is in portrait orientation.
Does anyone have any suggestions for fixing this problem? An example project with this sort of set-up would be ideal.
You can certainly use a navigation controller on the detail view of a split view controller. In fact, the iPad Settings app uses this approach. Probably the best way to get this setup is to create a new project in Xcode 4.x and select the "Master-Detail Application" template. It will generate a split view controller with 2 navigation controllers, one for the left view and one for the right view.
To your toolbar question, to keep things simple I would put a toolbar in the bottom. You can still put bar button items on the top navigation bar, although you can only put them in the left, middle, or right. If you need lots of items on the top bar, one way is to add a toolbar to the detail view and hide the navigation bar in the viewWillAppear event of the detail view class.
Here is an example on how to hide the navigation bar and show the toolbar:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.toolbarHidden = NO;
self.navigationController.navigationBarHidden = YES;
}
I've found the built-in UISplitViewController to behave badly when trying to combine it with most of the other built-in view controller subclasses. Matt Gemmell's MGSplitViewController is a lot more flexible and has worked pretty well for me, despite the odd glitches (though those are at least fixable as the source code is provided).