- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
if (self.fullScreenVideoIsPlaying == YES)
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
if(self.window.rootViewController)
{
UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presentedViewController supportedInterfaceOrientations];
}
return orientations;
}
}
I try to change screen orientation only one page and i add this function when i start program, program could not start give this error initial screen
Error :
2015-02-06 00:40:24.264 AppName[5002:1189245] -[SplashScreen viewControllers]: unrecognized selector sent to instance 0x14d510010
2015-02-06 00:40:24.266 AppName[5002:1189245] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SplashScreen viewControllers]: unrecognized selector sent to instance 0x14d510010'
*** First throw call stack:
(0x18269659c 0x192da00e4 0x18269d664 0x18269a418 0x18259eb6c 0x100098614 0x186ebc594 0x186ebc210 0x186ec548c 0x186ec4ee0 0x186ebc154 0x1870d45f0 0x1870d362c 0x1870d1dec 0x18a90d62c 0x18264ea28 0x18264db30 0x18264bd30 0x1825790a4 0x186eb33c8 0x186eae3c0 0x100102560 0x19340ea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any idea ?? How can i fix this issue ?
Maybe you want to change viewControllers to childViewControllers
EDIT 1: Sorry I only noticed now that you think your rootViewController is a UINavigationViewController.
It is clearly not as you can see form the error message. It's of class SplashScreen
EDIT 2: I suggest you do the following and take it from there
if(self.window.rootViewController && [self.window.rootViewController isKindOfClass:[UINavigationViewController class]])
{
UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presentedViewController supportedInterfaceOrientations];
}
return orientations;
Related
My application is is landscape mode. I am presenting the activity view controller in landscape only with the following lines of code:-
NSArray *shrArr = [NSArray arrayWithObjects:[NSString stringWithFormat:#"%#", KHL_SHARE_TEXT], nil];
UIActivityViewController *shareUIAVC = [[UIActivityViewController alloc] initWithActivityItems: shrArr applicationActivities: nil];
if([shareUIAVC respondsToSelector:#selector(setValue:forKey:)])
{
[shareUIAVC setValue:KHL_SHARE_MAIL_TEXT forKey:#"subject"];
}
if([shareUIAVC respondsToSelector:#selector(popoverPresentationController)])
{
shareUIAVC.popoverPresentationController.sourceView = self.menuButton;
shareUIAVC.popoverPresentationController.sourceRect = self.menuButton.bounds;
}
[self presentViewController:shareUIAVC animated: YES completion: nil];
The Activity view controller opens in landscape and on choosing either message or mail and either sending or cancelling the message or mail composer, the app crashes with the following logs.
* Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation '(7)' must match a supported interface orientation: 'landscapeLeft, landscapeRight'!'
* First throw call stack:
(0x186f991b8 0x1859d055c 0x186f99100 0x18cf44670 0x18d810428 0x18d19abf0 0x18d1be6c8 0x18cf7b1bc 0x18cf21f14 0x18d1bd920 0x18cf21a48 0x18d7f672c 0x18d7f6a64 0x18d067bdc 0x18d7d5ad4 0x1974b498c 0x1974cbad8 0x186f9f150 0x186e91eac 0x188b6f92c 0x188b6f798 0x188b48058 0x18d0d1684 0x18d126664 0x18a293e10 0x18a26b4c4 0x18a292a68 0x18a293488 0x186f460c0 0x186f43cf0 0x186f44180 0x186e722b8 0x188926198 0x18ceb97fc 0x18ceb4534 0x100143930 0x185e555b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
2017-06-01 16:36:17.423693
As suggesting from various sources here , I added the following code too, but that does'nt work either
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
Thanks in advance!
Add this in appdelegate
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
//self.isMailController enable while activityViewcontroller appears and disable while it dissmissed.
if(self.isMailController){
// you can check multiple viewcontroller
return UIInterfaceOrientationMaskPortrait; // if your mail viewcontroller it will display on portrait
}
return UIInterfaceOrientationMaskLandscape;
}
I just build a class to manage correctly my database and JSON request. The problem is that now, how can I perform the segue ?
Here is my code
In my view :
- (IBAction)loginClick:(id)sender
{
NSString *post = [NSString stringWithFormat:#"username=test&password=test"];
[[DataManagement sharedManager] WebServiceLogin:post];
}
- (void) showTypeView
{
[self performSegueWithIdentifier:#"showTypeView" sender:nil];
}
In my class :
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
...
switch ([[response valueForKey:#"success"] intValue])
{
case 0:
{
NSLog(#"error: %# error Description: %#", [response valueForKey:#"success"], [response valueForKey:#"error_message"]);
break;
}
case 1:
{
LoginViewController *showView = [LoginViewController new];
[showView showTypeView];
break;
}
default:
break;
}
...
}
When I launch, I have an error :
**
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<LoginViewController: 0x165afd30>) has no segue with identifier 'showTypeView''
*** First throw call stack:
(0x2592e2eb 0x250fadff 0x29e2b037 0xe1819 0xdb64f 0x25f64de1 0x25f64d99 0x25f64e8d 0x25e261ef 0x25edf04f 0xa77cab 0xa7f835 0x25e171e3 0x258415f9 0x25e170cb 0x25e16f95 0x25e16e29 0x258f1257 0x258f0e47 0x258ef1af 0x25841bb9 0x258419ad 0x26abbaf9 0x29b2dfb5 0xe3ea9 0x254f4873)
libc++abi.dylib: terminating with uncaught exception of type NSException
**
If you're using segueWithIdentifier then you need to already have the segue built in Storyboard and labeled correctly as "showTypeView". Otherwise you should use a navigation controller to push a view controller or use self presentViewController to show a modal view controller.
EDIT:
Building off of Larme's comment, you can build a delegate like this:
// In your class.h file
#property (weak, nonatomic)id<SegueDelegate> delegate;
// In class.m file
LoginViewController *showView = [LoginViewController new];
self.delegate = showView;
[self.delegate segue];
// In LoginViewController.h
#protocol SegueDelegate
-(void)segue;
#end
#interface LoginViewController: UIViewController <SegueDelegate>
-(void)segue;
#end
// In LoginViewController.m
#implementation LoginViewController
-(void)segue
{
[self performSegueWithIdentifier:#"showTypeView" sender:nil];
}
#end
I have an universal app where I successfully upgraded the iPhone component to ios7.
The ipad component however is not running anymore. I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISplitViewController tabBar]: unrecognized selector sent to instance 0x8d9eef0'
I have no idea what happened. I did not touch the ipad side of things whatsoever.
I am running: 11A4449d build and 5A11365y build for x-code on a mac machine.
After this code the error happens:
- (void) awakeFromNib {
[super awakeFromNib];
// whenever I come out of a storyboard, I make myself the delegate of any splitview I am in
self.splitViewController.delegate = self;
}
In this method: I set the selected image on a tab bar for the iPhone.
But did not realise that the iPad will not like it. So I put a selective statement (if !iPad) around it to fix it.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
BOOL piPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
if (!piPad)
{
// **************************************************************************************************
// Assign tab bar item with titles and selected images
UITabBarController *pTabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *pTabBar = pTabBarController.tabBar;
UITabBarItem *pTabBarItem0 = [pTabBar.items objectAtIndex:0];
pTabBarItem0.title = #"List";
pTabBarItem0.selectedImage = [UIImage imageNamed:#"tabBarList_30x30_selected"];
pTabBarItem0.image = [UIImage imageNamed:#"tabBarList_30x30.png"];
// **************************************************************************************************
}
return YES;
The error is not every time.
i had try to clean and rebuild app,but it is also.
error:
*** Assertion failure in -[UIWindowController
transition:fromViewController:toViewController:target:didEndSelector:],
/SourceCache/UIKit_Sim/UIKit-2372/UIWindowController.m:211
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Attempting to begin a modal transition from
<UINavigationController: 0x9190730> to <UINavigationController: 0x83a9dc0>
while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear
to know the current transition has completed'
*** First throw call stack:
(0x213d012 0x1e85e7e 0x213ce78 0x191bf35 0x10b8d05 0xeb74f3 0xeb7777 0x10be033f
0xeb77b7 0x104f0 0x1e996b0 0x18c6035 0x20c0f3f 0x20c096f 0x20e3734 0x20e2f44
0x20e2e1b 0x36437e3 0x3643668 0xdcd65c 0x1133f2 0x25c5)
libc++abi.dylib: terminate called throwing an exception
BaseController.h:
#class LoginViewController;
#interface BaseController:UIViewController
//...
#end
BaseController.m
#implement BaseController
//...
-(void)showLoginForm
{
UIViewController* loginx =(UIViewController*) [[LoginViewController alloc] init];
UINavigationController* navx = [[UINavigationController alloc] initWithRootViewController:loginx];
[navx.navigationBar setBackgroundImage:[UIImage imageNamed:#"title_bar.png"] forBarMetrics:UIBarMetricsDefault];
//added
//i can use #try to catch it
[self presentModalViewController:navx animated:YES];//<====it is error
[loginx release];
[navx release];
}
LoginViewController:
#interface LoginViewController:BaseController
//...
#end
otherViewController:
i will judge the user is login or not in this controller.if it is not login,i will call showLoginForm
//#interface otherViewController:BaseController
//......
-(void)viewDidLoad
{
//make a thread to call isLogin
}
-(void)isLogin
{
BOOL logined = YES;
//......
if(!logined)//i take this on MainThread,it has error also.
[super showLoginForm];
}
MainViewController:(it is the Main ViewController to show otherViewController)
//#interface MainViewController:BaseController
//......
-(void)buttonAction
{
otherViewController* other = [[otherViewController alloc] init];
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:other];
[self presentModalViewController:navigation animated:YES];
//release
}
so ,Who knows how this is going on?
In otherViewController.m you should move the code that calls the isLogin method to
- (void)viewDidAppear:(BOOL)animated
This will make sure that the transition for the presentation of the otherViewController will have finished when [self presentModalViewController:navx animated:YES]; is called.
I have the following code to display a magazine type app. When the app is rotated it runs this code. I made sure that it is only run when rotated to supported orientations. When this function returns, the app fails with a SIGABRT. There is no other indication as to why.
I know it's this function because when I remove it the program does not fail.
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{
//If portrait mode, change to single page view
if(UIInterfaceOrientationIsPortrait(orientation)){
UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
self.pageViewController.doubleSided = NO;
return UIPageViewControllerSpineLocationMin;
//If landscape mode, change to double page view
}else{
//Get current view
UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
//Create an array to store, views
NSArray *viewControllers = nil;
NSUInteger currentIndex = self.currentPage;
//Conditional to check if needs page before or after
if(currentIndex == 1 || currentIndex %2 == 1){
UIViewController *nextViewController = [self pageViewController:self.pageViewController viewControllerAfterViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:currentViewController,nextViewController, nil];
}else{
UIViewController *previousViewController = [self pageViewController:self.pageViewController viewControllerBeforeViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:previousViewController, currentViewController, nil];
}
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
return UIPageViewControllerSpineLocationMid;
}
//return UIPageViewControllerSpineLocationMid;
}
Alas, borrrden is probably right. One of your IBOutlets is probably missing from your XIB. Make sure ALL of your IBs are connected properly, and if the problem continues, say so.
Well you didn't provide the output from the console, which would be nice. Giving the code a quick look I would guess that one of your controllers (next or previous) is nil, and since you can't insert nil into an NSArray (except as the last object) it is throwing an error.
EDIT Well, my guess was wrong. The error message is saying that the UIViewControllers you are giving to it do not support the orientation that the page controller needs. This is because you have a method called shouldRotateToInterfaceOrientation: in your child UIViewControllers, and they are returning no for (in this case) left landscape.
I was getting the same error
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'All provided view controllers ((
"<ContentViewController: 0x6a7eac0>",
"<ContentViewController: 0x6d89f10>"
)) must support the pending interface orientation (UIInterfaceOrientationLandscapeLeft)'
Adding the following to my PageModel class, where the page layout is designed worked for me:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}