View controller IOS switch between views - iphone

I am new at ios programming and I need some help, can't figure out how I am going to switch between two views without firing a button event
I have a splash screen waits for 2 sec then it should go to main view. I don't know how I am going to acquire the main view's reference and navigate to main view!
Any tutorial about switching between views programmatically?
Thanks for your help.
Cheers

For Splash screen you have to name it Default.png and in appDelegate didFinishlaunchingMethod, you have to add view controller to window. the Default.png is automatically reference as a splash screen. try it out

Start with one of Xcodes default projects, and see how they are setup. They should give you a window, with a main view out of the box.
If you add a Default.png image file to your project, it will automatically be used as a splash screen and displayed upon startup. However it will not be visible for 2 seconds, but rather as long as it takes for the application to start.
If you want it to be displayed longer, you will have to add a UIImageView with the same png image to your mainview, then remove this from your mainview after two seconds.
You can use performSelector:withObject:afterDelay to trigger the hiding of the UIImageView after a period of time. However this goes against Apples design guide, as the splash screen only is meant as a ting for the user to look upon before the application launches.
As for adding new views, I recommend using a UINavigationViewController. Using this enables you to navigate back to the main view, and you also get a nice animation as a transition between the views.

If you want to switch between views you use addSubview
maybe this tutorial will help ->Tutorial

Related

Splash screen with progression bar

I am working in a app I an considering making a splash screen with a uiprogression bar, taking the time the loading of the app lasts...
I am not sure how to do this.
Can anyone give me a few tips please.
PS: I am asking this because I think I cannot add a class to launchscreen... So is it possible to do this in the launchscreen? If so, how?
You can't do much on launchscreen since, even custom font's not are loaded on it. Just create initial navigation controller, where first view controller will have your progress bar, write a delegate for your progress bar so when it will finish loading it will do action.
You can't do anything on launch screen. But If you want to show uiprogress bar on launch screen then you have to design a view controller just like your launch screen and show it right after launch screen, do your work while uiprogress bar is showing when you finish your work then show next controller.

pushViewControllerAnimated pushes ViewController over whole screen

I am trying to show a modal view controller that hovers over another viewcontroller. Now the problem is when I use pushViewControllerAnimated the view controller that gets pushed will be as big as the whole iphone screen. I just want it to be half size of the screen.
How to adjust the size?
What exactly do you mean by half size of the screen?
If you are interested in the Facebook-like side menu, have a look at:
https://github.com/Inferis/ViewDeck
or https://github.com/BenHall/ios_facebook_style_navigation
If you are interested in an alertview-like small modal view controller, you might:
Consider using an alert view and adding some subviews
Read http://devblog.bu.mp/easy-partial-screen-modals-on-ios if you really have to use an UIViewController for that, which is not recommended by Apple (http://blog.carbonfive.com/2011/03/09/abusing-uiviewcontrollers/)
Hope this helps.

how to open a new view whilst keeping an old one visible

I have seen quite a few apps on the app store which display adverts at the top or bottom. I have managed to get adverts to work that is not the problem.
What i was wondering is how do you keep the same advert visible when you load a new view?
I am currently using the present and dismiss modal view functions to navigate through my app.
Thank you,
Mark.
Retain the advertView in a singleton class/AppDelgete (Means Keep this advert view as global and show it on each viewdidLoad) .
You can add the view as a subview of the window. You might have to bring the view to the front. However this approach will need to observe orientation changes and rotate the view appropriately. While this is possible, such a view might make the animations feel odd.

Media Type Splash Screen in iPhone iOS

Wanna create a custom splash screen for the iPhone, but Im asking for opinion from all of you.
For what I understand, the splash screen is only a image (Default.png), so if I want to make the splash screen longer, the only way I can do is create a image then add the subview to the front? Then create a timer to call a method to remove the image from the view.
But then I want to create a media type splash screen, which will show audio, video and etc. So the question is what flow will it look like. The only way I think of is create a ViewController, then present it in a modal view. Later I also will add in an option to detect a tap from user, if tapped then the media will quit/hide/dismiss the fake splash screen and present the main view controller.
For now the flow of my thinking is like this:
AppDelegate --> RootViewController --> SplashViewController(Modal View)
is it possible to make it like this?
AppDelegate --> SplashViewController --> RootViewController
Is there any other way to show the media when the app start?
Any answer is appreciate, thank you in advance.
set the root view controller of your navigation controller to Be your splash screen.
Then just dont allow the user to navigate that low.
after the timer lapses, push onto the nav with animation:NO and your splash screen will be replaced.
Alternatively you can add your splash.. and when the timer lapses, you tell the splash screen to remove itself from its parent view, then add your root controller.

(iphone) pushViewController in background thread?

IPhone SDK - Leaking Memory with performSelectorInBackground
seems to suggest you can actually pushViewController in background thread.
But I get a warning from stackoverflow people that I shouldn't do this.
eg. (iphone) start timer from background thread?
is pushViewController considered "UI updating"?
(because I know that UI updating should be done in main thread only)
If it is so,
when a viewController takes a while to load, and want to show an indicator while loading.
What is my option?
Couple of strategies here.
1) BEFORE you do the push, but at the point you know you are going to do it, bring up a suitable activity view on the current view. I do this in some apps where you click on a row in a table but the pushed view has to do some web comms that takes time, so I leave the table cell highlighted in blue and add a white spinner to the left of the disclosure indicator. Works well.
2) Use lazy loading to get the new view controller on screen quickly, but defer the heavy code until after it has loaded so that the new controller can look after it's own activity view. By lazy loading I mean you should do as little as possible in the init method and make careful use of viewdidload / viewwillappear / viewdidappear etc to spread the work out and get an activity view on screen as soon as you can.