In my app, the rotation works fine in iOS7 but not working in iOS8.
As you can see, the status bar rotates, but the view controller does not.
I found the issue is caused by main storyboard setting, but I have no idea why it cased the issue. I just removed main storyboard setting in project file and everything works fine in iOS8.
Following is my codes to load storyboard.
[self setMainStoryboard:[UIStoryboard storyboardWithName:#"MainStoryboard-ipad" bundle:nil]];
UIViewController *vc = [mainStoryboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
[self.window setRootViewController:vc];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
Maybe I used the wrong way to load storyboard?
I fix the problem, but I think this might not be a good solution. It's just a workaround. Anyway, here is what I have done. If you run into the same problem, you can try removing main storyboard setting in your target.
That's it, no further steps. Everything is fine after I remove main storyboard setting. Maybe the way I load main storyboard is incorrect or there is something wrong with my setting of storyboard.
Following is the codes I used to load storyboard:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Storyboard" bundle:nil];
UIViewController *vc = [storyboard instantiateInitialViewController];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
// Override point for customization after application launch.
[self.window setRootViewController:nav];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
If anyone know the correct way to use main storyboard, please give me some feedback. Thanks!
Related
So I had a full working solution in iOS7 that displays a LoginViewController via presentViewController in the AppDelegate's didFinishLaunching.
Basically I am doing something like this:
UIViewController *backgroundViewController = ...
self.window.rootViewController = backgroundViewController;
[self.window makeKeyAndVisible];
[self.window.rootViewController presentViewController:loginViewController
animated:NO ...]
In iOS8 I see a jump. First I see the backgroundViewController then after about 1 second or so the login appears.
So, how can I prevent this jump in iOS8?
I am seeing that are a ton of developers with this kind of problem but still didn't find a solution.
Also a hack (for now), but just one line of code
Add the view of the view controller you're presenting to the window before presentation
UIViewController *viewController = [[UIViewController alloc] init];
[viewController.view setBackgroundColor:[UIColor greenColor]];
// Temporary iOS8 fix for 'presentation lag' on launch
[self.window addSubview:viewController.view];
[self.window.rootViewController presentViewController:viewController animated:NO completion:nil];
If you are presenting a navigation controller than add the navigation controller's view instead of its top view controller.
I have a quick hacky fix:
//Make a screenshot of the ViewController first, or use a real image if you want
__block UIImageView *fakeImageView = [[UIImageView alloc] initWithImage:image];
fakeImageView.frame = vc.view.frame;
[self.view addSubview:fakeImageView];
[self presentViewController:vc animated:animated completion:^{
[fakeImageView removeFromSuperview];
fakeImageView = nil;
}];
It is not good for long term, but can quickly fix this issue without changing too much code.
Waiting for better solutions.
You can set the window to an instance of a temporary controller.
self.window.backgroundColor = [UIColor whiteColor]; //do some styling etc.
self.window.rootViewController = [LoginViewController new];
[self.window makeKeyAndVisible];
From the set controller (LoginViewController) you can push your real login controller with the desired transition. Once the login sequence is over you can make a transition from the login controller to the default application root view controller.
[UIView transitionWithView:[AppGlobal sharedApp].applicationWindow
duration:0.75
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
[AppGlobal sharedApp].applicationWindow.rootViewController = [AppRootViewController new];
} completion:nil];
I have also faced the same problem in iOS8 and I found this solution:
ABCViewController *obj = [[ABCViewController alloc] initWithNibName:#"ABCViewController" bundle:nil];
CATransition *transition = [CATransition animation];
transition.duration = 0.4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromBottom;
transition.delegate = self;
[self.navigationControler.view.layer addAnimation:transition forKey:nil];
[appDelegate.navigationControler obj animated:NO];
obj = nil;
I hope this solution can help you!
This should work:
call [loginViewController view]
Before presenting it.
i want to add Airdrop sharing to my spritekit game
It dosent work using this code:
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil]
I am thinking the issue is where you have the code you posted. You possibly have it in viewDidLoad of your UIViewController.
Do this in your UIViewController :
-(void)viewDidAppear:(BOOL)animated
{
// assuming you are creating objectsToShare here or before this point
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil]
}
I believe the issue is that the view is not fully configured when you are trying to add your UIActivityViewController.
I believe that the bounds and some other properties of the view are not yet properly configured in the viewDidLoad method, which results in a failure to display it.
I am new in iPhone/Ipad Application development and Just learning the UIViewController, UIView etc with Xcode and while using uiviewcontroller want to resize but my tricks logic are not working. please let me know if you have any Idea with this.
Thanks
i think your are looking like this.
(IBAction)buttonPressed:(id)sender
{
menuView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"bgground.jpg"]];// i used 1 view name is menuView
UIViewController *menu =[[UIViewController alloc] init];menu.view = menuView;
[menu setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:menu animated:YES];
[menu release];
}
After resize try this code
UIViewController* view = [[UIViewController alloc] init];
[self presentModalViewController: view animated: NO];
[self dismissModalViewControllerAnimated: NO];
[view release];
My DetailView of a SplitView has a Map with Annotations. Upon clicking an Annotation the entire window (and not just the DetailView) should go to another view. Unfortunately that doesn't work.
This is how I'm creating my NavigationController in my AppDelegate
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window addSubview:navigationController.view];
This is how I'm creating the SplitView
left = [[MapSplitViewLeft alloc] initWithStyle:UITableViewStylePlain];
right = [[MapViewController alloc] init];
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:left,right, nil];
self.view = splitViewController.view;
left.right = right;
[left release];
[right release];
And that's what's being called when clicked on an Annotation:
- (void)showDetails:(id)sender {
NSLog(#"Yes it works");
VenueViewController *vviewcontroller = [[VenueViewController alloc]
initWithNibName:#"VenueViewController" bundle:[NSBundle mainBundle]];
AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate;
[del.navigationController pushViewController:vviewcontroller animated:YES];
}
When I click on the Annotation I only get "Yes it works" but nothing else is happening.
Thanks so much for any advise.
Every UIViewController has the property "navigationController". Try with your current ViewController to push the new Viewcontroller.
[self.navigationController pushViewController:vviewcontroller animated:YES];
edit: Sorry, you mean the entire window! I think that would not work.
edit2: Maybe this answer can help you how to add a view over window in uiviewcontroller But i think thats that view is not on your navigationController-Stack
I am tired try open a modal view controller from ipad application.
How I can show a modal view like formsheet?
here my code block.
like this style opening a window (full screen) but there is don't have any object from my modal view
viewDetail *hd = [[viewDetail alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:hd];
hd.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentModalViewController:nav animated:YES];
[hd release];
[nav release];
just i want open a formSheet modal view when selected a value from UITableView
by the way, i am development on xcode 4.2.1 and usind storyboard features
thanks for help.
like that give a SIGABRT error
viewDetail *hd = [[viewDetail alloc] initWithNibName:#"viewDetail" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:hd];
hd.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentModalViewController:nav animated:YES];
[hd release];
[nav release];
I fixed my solution, worked a xib file out of story board.
But why wasn't it working in storyboard? There is a way for that?
If you're using storyboards, you have to set [self.storyboard instantiateViewControllerWithIdentifier:#"viewDetail"]; as your viewDetail View Controller. (Assuming you set the Storyboard Identifier accordingly)
hope that helps.