I'm working with iPad. I want my app to fix at lanscape mode only. My app contains a split view controller and above split view controller I placed login screen.
After user provides the necessary username and password, the login view should be removed so that split view controller gets opened. It works good. But i want login screen to be set at landscape mode. I tried in so many ways but my problem is still not solved. I placed a UIOrientaion key with value lanscape in a plist. But no use.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//UIInterfaceOrientationLandscapeLeft;
// Overriden to allow any orientation.
// return UIInterfaceOrientationIsLandscape(interfaceOrientation);
return YES;
//return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
I tried in this way also but no result.
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
Also in this way in viewdidload,
By using this way im able to set the app in landscape mode but the view is not rotated to landscape.The login view is fixed at potrait mode.
In nib file,if i fix the view in lanscape,the split view's,rootviewcontroller appears on on e side and in the detailviewcontroller of splitviewcontroller,this login screen is opened that too in potrait mode.....
Any help will be appreciated
Thanks in advance
i found solution to my problem.Here is the coding:
[ViewController *newDetailViewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
[window addSubview:newDetailViewController.view];
[window addSubview:anotherViewController.view];
[window bringSubviewToFront:newDetailViewController.view];
In this way we should add subviews to delegate.After that fix the view in landscape by auto rotation method in view controllers..thats it
Related
I am recently facing an issue in my app on iphone 6+ IOS8.3. The issue is i am using uitabbarController in my app and each tab of tab bar controller contains a uinavigationController.
Now when i select the 6th/7th tab by going into More tab and then rotate the screen then black screen appears.
To test the scenario i made an saperate applictaion and make the same structure, i.e made 9 tabs and each tab contain navigation controller. All this is done on storyboard and no code was written.
Then i run the app and select the 6th tab and rotate the screen, the black screen appears. and when i rotate back to portrait then everything become fine again.
I am attaching the screen shots for further explanation.
So anyone able to tell why it turns into black screen? I am doing it wrong ? or That is a bug of IOS8.3 or something else?
I ran into the same issue today and since this question has not been answered yet, I'd like to present my simple solution.
In your UITabbarController subclass, subscribe to the rotation events:
[[NSNotificationCenter defaultCenter] addObserver:self //Add yourself as an observer
selector:#selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
Add the following code to the rotation observer method:
- (void) orientationChanged:(NSNotification *)notification {
if (IS_IPHONE_6P) { // some magic to figure out if we're on iphone 6 plus
self.customizableViewControllers = #[]; // we don't want an edit button to appear
if (self.selectedIndex == 5 || self.selectedIndex == 6) { // the effect only happens to view controllers at index 5 and 6.
[self.moreNavigationController popToRootViewControllerAnimated:NO]; // pop the view controller from the moreNavigationViewController
self.selectedViewController = self.viewControllers[self.selectedIndex]; // set the selected view controller to be visible again.
}
}
}
I have an iOS 6 app that I am updating to work with iOS 7 and to make it use storyboards. I am trying to use multiple storyboards so that I can break my project down into modules for each screen in the app. So far this has worked out fine but now I need to provide a way to navigate between the various storyboards while still making the work like it did in iOS 6 (but with updated artwork).
I don't use UINavigationController in my existing iOS 6 app and I would prefer not to use it as up to now I have been able to navigate back and forth between XIB's using code on UIButton tap gestures. The UINavigationController doesn't make it easy to customise how the navigation buttons look from what I have learned so far about it.
I found this very clean way of moving between view controllers that are on different storyboards https://github.com/rob-brown/RBStoryboardLink by passing the name of the storyboard in as an attribute.
But it only seems to work when UINavigationController is used. I get an error "Push segues can only be used when the source controller is managed by an instance of UINavigationController" without UINavigationController.
Is there a way to navigate between storyboards by only using the above RBStoryboardlink but without the need for UINavigationController?
Push segues can only be used when the source controller is managed by an instance of UINavigationController
This means you are trying to push a view controller to the source while source don't have any navigation controller stack.In that case, you should try to add the instantiated view controller's view as subview to the source view controller's view.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
[self.view addSubview:viewController.view];
or you modally present, that purely depends on your requirement.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
tabBarViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:tabBarViewController animated:NO completion:NULL];
I am attempting to follow this example: http://howtomakeiphoneapps.com/uiwebview-tutorial/239/
I have added a UIWebView into my view (using Storyboard)... I added the IBOutlet to my .h controller file. (see image at: http://imgur.com/GfUmC). I added a delegate to the view controller like this:
#import <UIKit/UIKit.h>
#interface slWebViewController : UIViewController <UIWebViewDelegate> {
IBOutlet UIWebView *slWebView;
}
#end
Since I'm using XCode 4, I don't know how to set the UIWebView's delegate to the File Owner, which is why I think this is what I'm getting a black screen. I'm missing something, but I don't know what. At this point, I would really, really appreciate any help I can get solving this...
In your Storyboard, right click (or ctrl-click) and drag from your UIWebView to the File's Owner on the left side, and choose "delegate".
Alternatively, select the webView (as in your image). Note the top outlet, "delegate". Drag from there to the File's Owner.
Or you can code it. In viewDidLoad, type "self.sIWebView.delegate = self;"
All of this is assuming that you have your URL request right. In case you don't, here's an example:
NSURL * url = [NSURL URLWithString:#"http://google.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url
cachePolicy: NSURLRequestReloadIgnoringCacheData
timeoutInterval: 10];
[sIWebView loadRequest:request];
EDIT: If you are presenting the webView modally, add this code to the view controller that segues to your webview: -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([segue.identifier isEqualToString:#"SegueIdentifier"]) { WebViewController *webView = segue.destinationViewController; webView.delegate = self; } } You'll need to add an identifier to your segue. Just click on the segue itself, go to the third tab from the right, and type in an identifier.
UPDATE: I've isolated the problem to the webViewConroller.m file. Everything is connected properly. If I place the loadRequest code in the viewController at viewDidLoad, I see Google. If I place the loadRequest code in the "webViewController", and mark the ViewContoller as a custom class of webViewController, I get the black screen. I'm wondering if there isn't a better way to get the UIWebView to display content? I really don't need a controller for the webView, just when the segue for that cell is tapped, display the contents of the UIWebView... not sure I can do it with XCode...
I have been struggling with switching between views using the UINavigationalController. I have used this system many times without issue but in my new app it isn't working properly.
Here is the issue:
When i am pushing a new view controller i use the following code:
NewViewController *newVC = [[NewViewController alloc] initWithNib:#"NewView" bundle:nil];
[self.navigationController pushViewController:newVC animated:YES];
[newVC release];
The code I am using to return to the previous view inside of the newVC is:
[self.navigationController popViewControllerAnimated:YES];
I was reading that this could potentially be releasing the self.navigationController itself so I implemented this code:
UINavigationController *nc = [self navigationController];
[nc popViewControllerAnimated:YES];
What results is a smooth transition to the newVC with no white flash, but when returning to the original page the screen flashes white as if it is releasing the newVC before transitioning back to the original page. HOWEVER! When debugging I placed breakpoints on viewWillAppear of the original page and on the dealloc of the newVC and the viewWillAppear + transition with white flash all complete BEFORE the dealloc of the newVC is called.
If anyone could please help shine some light on this I would greatly appreciate it.
Thanks!
~Arash
This is an old post, but for those who may run into this issue in the future, I have solved it by setting the clipsToBounds property of the view of the ViewController to "TRUE"
-(void)viewDidLoad {
[super viewDidLoad];
self.view.clipsToBounds = YES;
}
Try changing the background colors of the various views on the navigation stack to different recognizable colors (including the main window). One of them might be showing for some reason, and if each one has a different color you can determine which one is the culprit pretty easily.
FWIW, this same issue happened for me in a Swift app. The root cause appeared to be that I was doing this:
self.navigationItem.rightBarButtonItem = nil
...to dynamically hide the button, where the UIBarButtonItem had an outlet in the current UIViewController.
I did not actually need an IBOutlet for that button, so I removed the outlet, and it worked.
I currently have a tab bar controller set up with a navigationcontroller on one of the tabs, then I have a UITableView nib set up for that Navigationcontrollers view. All of this has been set up through IB and I want to keep it that way. Kind of like this tutorial http://twilloapp.blogspot.com/2009/05/how-to-embed-navigation-controller.html
now the view loads perfectly when ViewDidLoad is called. But when I then load further views via code IE
MyApp_AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *nav = (UINavigationController *)delegate.controller.selectedViewController;
newViewController = [[newViewController alloc] initWithNibName:#"newView" bundle:nil];
[nav pushViewController:newViewController animated:YES];
//At this point the view works! and loads
If I try to go back with the navigation toolbar it goes back to my previous view fine
Now I need to refresh the tableview when I go back but calling viewDidAppear does not work.
I tried adding UINavigationDelegate to the same ViewController Class as the tableview and then calling - (void)navigationController:(UINavigationController *)navigationController didShowViewController:
But that did not work. I also tried adding the same delegate as the tab bar controller and adding the same navigationController didShowViewController: there but that also failed.
How do I get this table to refresh every time the view loads?
You should not have to call viewDidAppear from your code. Cocoa Touch should do that for you.
Call the table view's reloadData method to get it to refresh its contents.
Found I was missing the Delegate declaration in the Interface file. doh! also I tried that in lots of places it only ended up working when I added it to the NavigationControllers first view (my table view)