In StoryBoard we can set it visually as below
How can we do the same thing using .Xib/nib file ?
[self presentViewController:self.infoController animated:YES completion:nil];
Above code is just using modal style but how to set transition style to Partial Curl.
You can do this using this code:
#import "InfoController.h"
- (IBAction)goToSecond:(id)sender {
InfoController *vc = [[InfoController alloc] initWithNibName:#"InfoController" bundle:nil];
vc.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:vc animated:YES completion:^{
//completion code here
}];
}
Related
I have a web view controller, suppose A
The weviewcontrollerA contain 2 button at top ButtonA and ButtonB
Now my question is
From Another ViewControllerX i load weviewcontrollerA by passing URL as parameter, to load www.google.com in the webviewControllerA view.
for example :
-(IBAction)loadweviewcontrollerA
{
weviewcontrollerA *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"weviewcontrollerA"];
vc.urltoload=#"https://wwww.google.com";
[self presentViewController:vc animated:NO completion:nil];
}
Now in webviewcontrollerA , i have to reload the same view again with below condition
1) Reloading the viewDidload (or present the same class again) is compulsory as i have to pass some Parameter in the uRL also as HTTPRequest with the weburl
2) how to dismiss webviewcontrollerA , and then suddenly load it again without user known it.
how i jump,below code work, but user see ViewControllerX and the it load again, how i skip that user not visible the ViewControllerX or it load so quickly without user notice
-(IBAction)ButtonA
{
[self dismissViewControllerAnimated:NO
completion:^{
weviewcontrollerA *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"weviewcontrollerA"];
vc.urltoload=#"https://wwww.facebook.com";
UIViewController *topvc=[self topMostController];
[topvc presentViewController:vc animated:NO completion:nil];
//[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:YES completion:nil];
}];
-(IBAction)ButtonG
{
[self dismissViewControllerAnimated:NO
completion:^{
weviewcontrollerA *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"weviewcontrollerA"];
vc.urltoload=#"https://wwww.twitter.com";
UIViewController *topvc=[self topMostController];
[topvc presentViewController:vc animated:NO completion:nil];
//[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:YES completion:nil];
}];
//----------- END OF MORE INFO POP UP VIEW---------------
- (UIViewController*) topMostController
{
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}
I have been developing an iPhone app and have come across a few issues. I do not have a storyboard in my app and have nothing in my xibs. I have initialised and set everything up through code. When I go to the GameViewController from my main viewcontroller everything is fine, however when I come back through my back button I get this issue:
Presenting view controllers on detached view controllers is discouraged .
When I re-arrive to the main view controller, there are little changes such as the view changing before its supposed to. Here is the code for the button on my
GameViewController *game = [[GameViewController alloc] initWithNibName:nil bundle:Nil];
[self dismissViewControllerAnimated:YES completion:NULL];
[self presentViewController:game animated:YES completion:NULL];
Here is the code for the back button:
ViewController *home = [[ViewController alloc] initWithNibName:nil bundle:nil];
[self dismissViewControllerAnimated:YES completion:NULL];
[self presentViewController:home animated:NO completion:NULL];
If anyone can help me to see what I am doing wrong that would be great.
You can not present home view controller from self because it is already dismissed. You should change
[self dismissViewControllerAnimated:YES completion:NULL];
[self presentViewController:home animated:NO completion:NULL];
to
UIViewController *parentViewController = self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^
{
[parentViewController presentViewController:home animated:NO completion:nil];
}];
Currently, when a button is tapped, a UIModalPresentationSheet comes up. I'd like to add a navigation bar at the top of this when it slides up. I've tried a lot of things but nothing seems to work. Here's what i'm currently trying and it returns this error.
AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:#"addAthlete"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete];
//[self.navigationController pushViewController:addAthlete animated:YES];
addAthlete.delegate = self;
addAthlete.modalPresentationStyle = UIModalPresentationFormSheet;
// UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addAthlete];
[self presentViewController:navigationController animated:YES completion:nil];
But it pushes it up modally, and without the modalpresentationsheet form. How can I make it so the navigation controller is sized correctly?
Try to change your code like this :
AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:#"addAthlete"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete];
addAthlete.delegate = self;
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
Because here, you try to present addAthlete from itself. So you get this error.
You should present navigationController in which you encased your addAthlete.
[self presentViewController:navigationController animated:YES completion:nil];
You are presenting from current viewcontroller itself.
Try something like,
[self dismissViewControllerAnimated:YES completion:^{
[self.parentViewController presentViewController: navigationController animated:YES completion:nil];
}];
I've unsuccessfully tried:
1. [self dismissViewControllerAnimated:YES completion:Nil];
2. [[self parentViewController] dismissViewControllerAnimated:YES
completion:Nil];
3. //from the parent view controller using a delegate
-(void)closeReplaceController
{
DLog(#"closeReplaceController");
[self dismissViewControllerAnimated:YES completion:Nil];
}
I would try something like this:
-(void)killPresentingView
{
UIViewController *vc = [self presentingViewController];
[vc dismissViewControllerAnimated:YES completion:nil];
}
And see what happens. If I understood you right, this should work.
Im calling this code from the MasterViewController in a UISplitVC for an iPad app:
-(void)viewWillAppear:(BOOL)animated{
//PRESENT MODALVC
ModalViewController *modalVC = [[ModalViewController alloc] initWithNibName:#"ModalViewController" bundle:nil];
[self setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:modalVC animated:YES];
}
but it doesn't work. No ModalVC appears.
Try this code:
ModalViewController *modalVC = [[ModalViewController alloc] initWithNibName:#"ModalViewController" bundle:nil];
[modalVC setModalPresentationStyle:UIModalPresentationFullScreen]; //You set the presentation style of the controller that would be presented, not the presenting controller
//This check is needed, because presentModalViewController:animated is depreciated in iOS5.0 and presentViewController:animated:completion must be used instead. The same is valid for dismissModalViewControllerAnimated and dismissViewControllerAnimated:completion
if([self respondsToSelector:#selector(presentViewController:animated:completion:)])
[self presentViewController:modalVC animated:YES completion:nil];
else
[self presentModalViewController:modalVC animated:YES];
If you are targeting iOS5.0+ only this check is not needed and you should use only presentViewController:animated:completion and dismissViewControllerAnimated:completion