Why UIModalPresentationPageSheet not working ... its always fullscreen - ios

Here is the code snippet for presenting view controllers as Form sheet.Its not working
It always comes as full screen
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"ViewController2"];
vc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:vc animated:YES completion:NULL];
I even tried ... preferred content size not works...

I think you are trying in iPhone.
Try this in iPad.
In iPhone its always full screen.
In iPad it will look as formsheet as per your expectation
If you want this to work in iPhone you have to try a third party library or do it yourself

Related

Blank view after pushViewController

Returning to iOS development after a year break, and its all mayhem.
When executing the 3 lines of code below, i see the screenshot of the emulator below.
I've also attempted to add the LoginForm view controller as the root view controller, as it should, except i also see a blank screen.
As shown in the screenshot of xcode, the naming all matches up. All the constraints are also blue.
I've included a NSLog in the viewDidLoad of the LoginForm, that i have seen log at points, but still nothing is displayed.
What am i missing, or doing wrong? I've got nothing from errors to work with.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:#"LoginForm"];
[self.navigationController pushViewController:view animated:YES ];
Try using
[self presentViewController:myVC animated:NO completion:nil];
Because your storyboard doesn't seem to be using navigation contoller.
If you Have Xib File
Viewcontroller1 *viewController = [[Viewcontroller1 alloc]
initWithNibName:#"Viewcontroller1" bundle:nil];
[[self navigationController] pushViewController:viewController animated:YES];
if you have Storyboard
Viewcontroller1*vc=[self.storyboard instantiateViewControllerWithIdentifier:#"Viewcontroller1"];
[self.navigationController pushViewController:vc animated:YES];

iOS - Modally Present VC with blur over previous View Controller

I'm attempting to present a VC modally that shows a blur of the previous view controller. This is my attempt. The problem is that this only works maybe 50% of the time. Half of the time the blur works as intended, the other half I only get the grey blur as if the background is black (no background content).
-(void)plusButtonPressedOnCell:(SASearchTableViewCell *)cell
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"ActionMenu" bundle:nil];
SAActionMenuViewController *actionMenuVC = (SAActionMenuViewController *)[storyboard instantiateInitialViewController];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:actionMenuVC animated:NO completion:^{
//animations
}];
}
Any ideas why this is happening?
My presentation style was incorrect, and I was attempting it on the wrong view controller. This was the fix.
This line:
self.modalPresentationStyle = UIModalPresentationCurrentContext;
needed to be:
actionMenuVC.modalPresentationStyle = UIModalPresentationOverFullScreen;

Multiple storyboards and view deallocation

I developed an application using only one storyboard and towards the end, when my app grew to have some 80 views, working in the storyboard was extremely difficult.
After some clicks the storyboard became non responsive/sluggish and I had to restart the xcode to get things back to normal.
So this time I decided to use multiple storyboards but I have the following problem. When I switch from one storyboard to the other, views on the storyboard I am popping from are not deallocated. As a result instruments show a continuous increase in memory allocations which is not acceptable.
Anybody knows how to dealloc the view in the second storyboard when I move back to the first ?
Bellow are the two ways I use for navigation
With one storyboard
-(IBAction)goToVcSameStoryboard:(id)sender{
[self performSegueWithIdentifier:#"segue" sender:self];
}
-(IBAction)backSameStoryboard:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
With two storyboards
-(IBAction)goToVcDiffStoryboard:(id)sender{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Storyboard1" bundle:nil];
UIViewController *initialVC = [storyboard instantiateInitialViewController];
initialVC.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:initialVC animated:YES completion:nil];
}
-(IBAction)backDiffStoryboard:(id)sender{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main_iPhone" bundle:nil];
UIViewController *initialVC = [storyboard instantiateInitialViewController];
initialVC.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:initialVC animated:YES completion:nil];
}

iOS 7 presentViewController shows black screen and SIGABRT

I use two buttons on right UIBARBUTTON by writing code in the method[ViewDidLoad].
http://i.stack.imgur.com/VcOEW.png
http://i.stack.imgur.com/vG3eT.png
http://i.stack.imgur.com/f0xsB.png
I want to use +plus button to move to AddNameViewController but it results in a Fail[sigabrt].
http://i.stack.imgur.com/MBq2m.png
http://i.stack.imgur.com/Hdw8T.png
I think the error is in the following code.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:#"AddNameViewController.m"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:YES completion:nil];
Change this:
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:#"AddNameViewController.m"]
For this:
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:#"AddNameViewController"]
You need the name of the View Controller, not the file.
Like Antonio said, you need the correct identifier for your view controller. The reason it crashes is because you get a nil view controller pointer back from the instantiateViewControllerWithIdentifier: call and passing nil to presentViewController:animated:completion: causes your crash.
check this
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:#"AddNameViewController"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:YES completion:nil];
and add identifier AddNameViewController in storyboard ID
Sorry, I did not check carefully before asking. Because I tried many ways to improve it. Although, I change AddNameViewController.m to AddNameViewController ,
It still show sigabrt.

UIModalTransitionStylePartialCurl not presenting viewController

I'm trying to implement a UIModalTransitionStylePartialCurl on a viewController to present a partial view of ViewController2 (I am using xCode 4.6 with storyBoards for a universal app). The following code does animate the UIModalTransitionStylePartialCurl but shows only a black window underneath. So, it works (no crash) but it won't present/show the second view ??
ViewController2 *v2 = [[ViewController2 alloc]init];
v2.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:v2 animated:YES completion:NULL];
You haven't initialized v2 . you should use this :
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Your_storyboard_name" bundle:nil];
ViewController2* v2 = [storyboard instantiateViewControllerWithIdentifier:#"Your_view_controller_identifier_from_storyboard"];
v2.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:v2 animated:YES completion:NULL];
Do any additional checks to see if it's iPad or iPhone and fill the information as is required.

Resources