I have problem with UIWindow size , in xcode 6 and ios 8 its worked fine, but when i start app from xcode 7 and ios 9 it did not correspond uiviews
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *mainViewController = [storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = mainViewController;
[self.window makeKeyAndVisible];
So i found problem , new xcode 7 off my LaunchScreen.xib and app was not full screen.
From https://forums.developer.apple.com/thread/5572, by Rincewind:
If you don't have any launch images, and you don't have a launch nib or storyboard, then you are declaring that you don't support any screen sizes aside from 320x480 (on iPhone/iPod). This has always been the case and is not new. Older Xcode Projects automatically generated a Default-568h.png to support 4" screens. This may have been invisible if you've used an iPhone 6 or iPhone 6 Plus, because if you had a Default-568h.png for 4" screen support, these devices scaled your app rather than letter boxed them.
A brand new project should not demonstrate any of these issues.
Related
I am new to Objective C, but with experience of C#. I have a project named "chat secure" (on github), but I don't know how the project works without storyboard. I would like to add storyboard to the project. Is it possible to use Storyboard along with other project?
Try this code
ShopObject *obj = arrDeals[indexPath.section];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"SwipeDealViewSB" bundle: nil];
StoryBoardViewController *swipeDealViewController = [storyboard instantiateViewControllerWithIdentifier:#"StoryBoardViewController"];
[self.navigationController pushViewController:swipeDealViewController animated:YES];
But remember to name your storyboard identify and custom class is"StoryBoardViewController" demonstrate image to identify storyboard
I've been using the following code untill now to get the storyboard:
NSString * storyboardName = #"myStoryboard";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
However, I now have a project with multiple targets, each with their own storyboard. This code no longer works, because the name of these storyboards is different for all targets. Is there a way to get the storyboard that is set as "main interface" in my target, without knowing the name of the storyboard at runtime?
In your UIViewControllers
Use
Storyboard *storyboard =self.storyboard;
instead of
Storyboard *storyboard =[UIStoryboard storyboardWithName:storyboardName bundle:nil];
My app is designed using a UITabBarController and im trying to present a view on top of that (a login screen) from the app delegate. When i use the following code:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
tabBarController = [[UITabBarController alloc] initWithNibName:#"Main_TabBarController" bundle:nil];
self.window.rootViewController = tabBarController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle:nil];
Login_ViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:#"Login_ViewController"];
[self.window.rootViewController presentViewController:lvc animated:YES completion:nil];
I get the error Warning: Attempt to present <Login_ViewController: 0x716fac0> on <UITabBarController: 0x7165240> whose view is not in the window hierarchy! and the screen is just black. How do i add Login_ViewController to the window hierarchy?
You can always grab the current root viewcontroller and use it to present your login controller.
UIViewController *presentingController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[presentingController presentViewController:viewController animated:YES completion:nil];
In addition, depending on how I want my login screen to look, I will push the login controller using UIModalPresentationFormSheet.
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
You're using two different mechanisms for creating your UI. You should move your tab bar controller into the storyboard. When you instantiate your storyboard, it overwrites your window with a new instance and the first controller as the root controller.
The error message is telling you the tab bar controller's view is not in the view hierarchy, not the other way around.
I would create a controller with a view consisting of just your application logo and inside of this controller determine whether you need to go to the login screen or not (if you have persistent logins). Then from the login screen transition to the tab bar controller.
Unless the storyboard you're loading isn't the main storyboard, you shouldn't need to load it manually. You should be able to set the storyboard as the main one for the application and iOS will load it automatically.
I am stuck in a problem which is related to ios 6. i have login view having two fields named username and password. after entering some text in both , user can login. after doing some task pressed a logout button and comes out at login view again but this time user cant type anything in the textfield. Its working in ios 5 but in ios 6 its cant. For finding the solution i have made again my app with xcode 4.5 just copied all code but all viewcontrollers are new. but i could not solved it.
I have done it in app delegate :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
[self.window makeKeyAndVisible];
[self.window setRootViewController:_navController];
[[UINavigationBar appearance] setBackgroundImage:[
UIImage imageNamed: #"top_barBG.png"] forBarMetrics:UIBarMetricsDefault];
_navController.navigationBarHidden = NO;
navimage = [[UIImageView alloc] init];
navimage.frame = CGRectMake(100, 25, 118, 32);
navimage.image = [UIImage imageNamed:#"Logo.png"];
[_navController.view addSubview:navimage];
return YES;
}
One Problem is more that is in inner view controllers where all i have textfields cant type anything while cursor is present with keyboard and resignFirstResponder is not working.
Please guys help me. it will be a great help.
The problem of text fields not working on iOS 6 comes from a window, from a xib, which is not set :
Take your first ViewController, which defines your rootviewcontroller. His xib is necessarily associated to a window : set the property "visible a launch" at true for this window.
I have started my iOS 5 app using a storyboard, however if I want to programatically modally present a view, how can I? I can't use initWithNibName as there are no longer nob files, but a storyboard.
E.g. this will give me a blank UINavigationView and not my Interface Builder one:
setupView = [[setupController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:setupView];
[self presentModalViewController:navigationController animated:YES];
If I use a button in interface builder (in my storyboard) and link the two views with it using 'Modal' it works a charm, but I want to do it programatically.
Thanks.
Turns out I think I have been looking for performSegueWithIdentifier and it works a charm.
Beginning Storyboards in iOS 5 Part 1 explained everything in details.