How to Animate iPhone New Screen towards Left - iphone

I am new bee in iPhone and just started development in it.
Learning a lot because of friends like you!
I just learnt how to go to another screen from current screen and i Did well due to tutorials from Internet.
But now the problem is when new screen comes up it animates from Bottom to Up and when we click DONE button to close the screen it goes from Up to Down. I have seen many applications in iPhone that animate the new screen from Right to Left and again from Left to Right.
What Piece of code do i need to add into the following to animate it toward left.
Please guide me Friends
MainScreen *screen = [[MainScreen alloc] initWithNibName:#"MainScreen" bundle:[NSBundle mainBundle]];
self.mainScreen = screen;
[self presentModalViewController:mainScreen animated:YES];

There are four different ModelTransitionsFor View Controllers.
You can set those for
screen.modalTransitionStyle = UIModalTransitionStylePartialCurl;
There are 3 other Styles you can check on Apple Site Link
If you need to do something like Navigation Style. you need to push your view controller to navigation stack.
[self.navigationController pushViewController:screen animated:YES];

Instead of this
[self.navigationController presentModalViewController:yourView animated:YES];
use this
[self.navigationController pushViewController:yourView animated:YES];

If you have Navigation based app then replace code with below.
MainScreen *screen = [[MainScreen alloc] initWithNibName:#"MainScreen" bundle:[NSBundle mainBundle]];
self.mainScreen = screen;
[self.navigationController pushViewController:screen animated:YES];

There are few modal view transitional styles available. Check apples documentation on this.
Also there are few uiviewtransitionanimation styles also described neatly in apple's guide.

Related

Same view on navigation in ios6

In my application i use the following code to navigate to a new view on receiving a click, It is working properly on iOS5. However, When i try with ios6 it is showing the current view and Is not goin to the next view. Do i need to change anything for ios6 in this code.
please help me to solve.
scoreview *sview=[[scoreview alloc] initWithNibName:#"scoreview" bundle:nil];
[self.navigationController pushViewController:sview animated:YES];
Try these lines:
scoreview *sview=[[scoreview alloc] initWithNibName:#"scoreview" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:sview animated:YES];
Can you please check your view is Correctly connected with UIInterfaceBuilder

ipad pushViewController display not as full screen

How to push an ViewController display not as full screen on iPad like the image below
Welcome any comment
Use UIViewController's modalPresentationStyle property, along with the standard presentModalViewController:animated:. Your screenshot is using UIModalPresentationFormSheet. There is also UIModalPresentationPageSheet, which displays fullscreen in portrait mode but leaves borders on either side in landscape.
The image you are showing is a type of modal view. You would display it with something like:
myViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[myViewController presentModalViewController: myModalViewController animated:YES];
See the documentation on UIViewController's for more info on modal views.
We can present the modalViewController in four different way .ie
1. UIModalPresentationFullScreen
2. UIModalPresentationPageSheet
3. UIModalPresentationFormSheet
4. UIModalPresentationCurrentContext.
Here you are using third One now..
if you dont want to use these thing simply use the following code..
[self presentModalViewController Animated:YES];
From the screenshot I take it that you're doing something like this:
UIViewController* newController = LoadTheController();
newController.modalPresentationStyle = UIModalPresentationFormSheet;
[currentViewController presentModalViewController:vc animated:YES];
But your question is referring to the "pushViewController" method, which is related to UINavigationController objects, and there is indeed a navigation controller in the background of the screenshot. You might try looking into something like this:
[currentViewController.navigationController pushViewController:vc animated:YES];

How come presentModalViewController is not working the second time?

I am using a tab based application that shows a presentModalViewController called "overview" that has 2 buttons on it .
In order to call it I am using the following code in app delegate:
Overview *overview = [[Overview alloc] initWithNibName:#"Overview" bundle:nil];
[self.tabBarController presentModalViewController:overview animated:YES];
When overview shows up, it has a button called that gets clicked and I am using the following code:
-(IBAction) btnLoginPressed{
[self dismissModalViewControllerAnimated:YES]; //get rid of view
Login *login = [[Login alloc] initWithNibName:#"Login" bundle:nil];
[self.tabBarController presentModalViewController:login animated:YES];
[login release];
}
However the login prsentModalViewController never shows up. Can someone explain why and what I can do to show it?
Thanks
When you present a modal view controller, you do it from the view controller currently in the view.
Assuming your second modal display of a view controller is happening in Overview.m change your code to the following:
-(IBAction) btnLoginPressed {
Login *login = [[Login alloc] initWithNibName:#"Login" bundle:nil];
[self presentModalViewController:login animated:YES];
[login release];
}
You don't need to dismiss Overview first, and in fact you shouldn't as it the animations won't work in conjunction with each other.
When you ultimately dismiss login (or however deep you want to go), you send dismissModalViewController:animated: as high up as you need to. To get back to the tab bar's controller use:
[self.tabBarController dismissModalViewController:animated]
It would be well beyond the scope of your question and the time I have to answer but you should take some time and really study the docs on implementing View Controllers. I definitely recommend following Apple's code style guidelines as one suggestion to make your code much more readable (e.g. overviewViewController vs overview). It's also clear you're just learning so keep at it.

How to do horizontal slice between views?

I'm looking for some advice about the best way to create a multi-view iPhone application. This app will slice left to right and right to left when a it goes from one view to another. Very similar to how a navigation-based application but without the navigation top bar.
I'm doing some tests using this code:
- (IBAction)goToSettings:(id)sender {
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:#"SettingsView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
something like UIModalTransitionStyleCoverHorizontal which doesn't exist.
So, I'm trying to do transitions, but now sure if that's the best way to do it, in terms of memory management, etc.
In summary, my application will have ~8 views, and I need to be able to navigate between them, going left to right into details, and go back to the left (previous view). What is the best way to do it?
Thanks in advance.
The navigation bar is optional in a navigation-based application. UINavigationController has a - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated method.
If for some reason that won't work, an alternative might be a paging UIScrollView, but that would be more hacky and more work to get what UINavigationController already gives you.

how can I call a screen with a button action (xcode)?

I am developing a Window Based app for iPhone. I use Interface Builder to build Interface. I want to call a new screen with a Button Action. How can I call the screen with Button action ?
By pushing the new controller onto the top of the stack of windows. For example:
EnterNameController *newEnterNameController = [[EnterNameController alloc] initWithNibName:#"EnterName" bundle:[NSBundle mainBundle]];
[[self navigationController] pushViewController:newEnterNameController animated:YES];
Apple has an extraordinary amount of sample code, and this question (as well as many others) could easily be solved by simply visiting Apple's iPhone dev site.
iPhone Dev Site
If you are using a navigation controller, push it onto the navigation controller's stack, as alamodey suggested.
If you want it to be a modal controller (that is, slide up from the bottom and cover the previous controller's view, like the Bookmarks screen in Safari), present it as a modal view controller:
[self presentModalViewController:myNewController animated:YES];
When you want to bring the old controller back, dismiss the modal view controller. From inside the modal view controller:
[self.parentViewController dismissModalViewControllerAnimated:YES];
If you don't want to do either, just remove the current controller's view from the window and add the new controller's:
UIView * containingView = self.view.superview;
[self.view removeFromSuperview];
[containingView addSubview:myNewController.view];
If you go this route, you may want to look into +[UIView beginAnimations:context:], +[UIView setAnimationTransition:onView:], and +[UIView commitAnimations] (if I recall the method names correctly--check the documentation) to animate the transition. You should almost always animate any switch between screens in iPhone OS.
(work in .m class)
#import "classtocall.h"
- (IBAction)ButtonPressed:(id)sender
{
classtocall *mvc = [[classtocall alloc]initWithNibName:#"classtocall" bundle:nil];
[self presentModalViewController:mvc animated:NO];
}
(for window based application)
define in .h class
- (IBAction)ButtonPressed:(id)sender;
where "classtocall" is the class you want to call.
you just need to download sample applications from XCode help. Try Elements and UIcatalog. There are also other - type 'pushViewController' or 'addSubview' adn 'makeKeyAndVisible' in help and download samples
nextscreenViewController *login = [[self storyboard] instantiateViewControllerWithIdentifier:#"nextscreenidentifier"];
nextscreenidentifier.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: nextscreenidentifier animated: YES];