How to fix the UIModalTransitionstyle issue on ios6? - iphone

I am using the following code for UIModalTransitionStyle view in my application when i click the button
InfoViewController *infoViewController = [[InfoViewController alloc]initWithNibName:#"InfoViewController" bundle:nil];
infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.presentedViewController presentViewController:infoViewController animated:YES completion:NULL];
its worked perfecly in ios5 but i update the application ios6 it not worked. How can I handle this issue

This code works, tested in iOS 6.0 simulator.
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:#"http://videoURL"]];
self.moviePlayerController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:self.moviePlayerController animated:YES completion:nil];
}
Since the URL is invalid, the MPMoviePlayerViewController will just endlessly flip back and forth, but the point is that it works.

Related

IOS 7 + For force controller Orientation to Portrait

I have used below code for IO6 and below to force rotate:
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIApplication* application = [UIApplication sharedApplication];
if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
{
UIViewController *c = [[UIViewController alloc]init];
[c.view setBackgroundColor:[UIColor redColor]];
[self.navigationController presentViewController:c animated:NO completion:^{
[self.navigationController dismissViewControllerAnimated:NO completion:^{
}];
}];
}
}
But it is not working correctly on IOS7, it rotate view controller but again set blank view on screen...
Can you help me to solve this issue in IOS 7...
Change this line:
[self.navigationController dismissViewControllerAnimated:NO completion:^{
}];
To this:
[self.navigationController dismissViewControllerAnimated:YES completion:^{
}];

presentViewController:imagePickerController is popping my navigationController?

I am using presentViewController:imagePickerController to display the UIImagePickerController. For some reason when I end up dismissing that controller my original navigation controller looses it's stack and my application is back at the root view controller.
I am logging self.navigationController.viewControllers and I can see that after I run the presentViewController:imagePickerController line my navigation controller looses all of its controllers except for the root controller.
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
imagePickerController.navigationBarHidden = YES;
self.imagePickerController = imagePickerController;
DLog(#"self.navigationController:%#",self.navigationController.viewControllers);
[self.navigationController presentViewController:imagePickerController animated:YES completion:^{
DLog(#" after presenting self.navigationController:%#",self.navigationController.viewControllers);
}];
////Closing it
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
DLog(#"self.navigationController:%#",self.navigationController.viewControllers);
[self.navigationController dismissViewControllerAnimated:YES completion:^{
}];
}
/////Where my NC is set up
OFMainViewController *mainController = [[OFMainViewController alloc]init];
mainController.managedObjectContext = self.managedObjectContext;
navigationController = [[UINavigationController alloc]initWithRootViewController:mainController];
[self.window setRootViewController:navigationController];
Instead of using self.navigationController use self for both dismissing and calling the imagepickerviewcontroller.
You should present imagePickeController on self instead of self.navigationController.
[self presentViewController:imagePickerController animated:YES completion:^{
DLog(#" after presenting self:%#",self.navigationController.viewControllers);
}];
And dissmiss it accordingly:
////Closing it
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
DLog(#"self.navigationController:%#",self.navigationController.viewControllers);
[self dismissViewControllerAnimated:YES completion:^{
}];
}

Why does iOS Simulator version 5.1 (272.21) close every time I try to switch to a second view?

The iOS simulator version 5.1 (272.21) closes every time I press a button to switch views.. any idea why?
- (IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
Thats the code for the buton on ViewController.m
By seeing your code, here is my idea,
If you are using XIB then use this way
- (IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
and if you are not using any XIB use this way..
- (IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] init];
[self presentViewController:second animated:YES completion:NULL];
}
That might help

iOS - EXC_BAD_ACCESS when executing a segue to MPMoviePlayerViewController

I am using Storyboard-
I am pretty new to this-
I'm getting a EXC_BAD_ACCESS (code=2, address = 0x4) error when I click a button pointing to a MPMoviePlayerViewController.
To give you an idea of what I've got so far: I have several different ViewControllers all under the same ViewController.h/m class with navigation controlled by a NavigationController. I started with a NavController and single ViewController and have been linking new ViewControllers with the simple CTRL-Click button-to-new-ViewController. I added a new ViewController; changed it's class to MPMoviePlayerViewController in the Custom Class section of the Identity Inspector, but I keep getting this error when I click on the button to begin the transition.
Here's my ViewController.h code if it's relevant:
- (IBAction)postToTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Check this out!"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
- (IBAction)postToFacebook:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"Posted from IOS App Test -- It works!"];
[self presentViewController:controller animated:YES completion:Nil];
}
}
- (IBAction)playVideo1:(id)sender {
NSURL * url = [[NSURL alloc]initWithString:#"link omitted"];
//create our moviePlayer
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
//Some additional customization
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
moviePlayer.shouldAutoplay = NO;
moviePlayer.controlStyle = MPMovieControlStyleDefault;
}

How can I use UIModalPresentationFormSheet with NavigationController in iPad?

I want to use UIModalPresentationFormSheet in my app. But i'm using navigation controller. So when i writes following code it is not responding me. What should i do ?
[self.navigationController pushViewController:controller animated:YES];
Try something like this:
// assume controller is UIViewController.
controller.modalPresentationStyle = UIModalPresentationFormSheet;
Then
[self.navigationController presentModalViewController:controller animated:YES];
Check with the below sample working code.
MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after
presentModalViewController targetController.view.superview.center = self.view.center;
Taken from -->
How to resize a UIModalPresentationFormSheet?