I have added iPhone 5 compatibility by adding the default-568h#2x.png
However, the tab bar in my application does not come in the bottom as should be expected.
This tab bar is added via tabbarController in mainWindow.xib.
NOTE: the bottom black part is clickable, but my view does not stretch itself to fit the screen.
I have tried the following already:
1) [window setFrame:[[UIScreen mainScreen] bounds]];
2) setting freeform/retina 4 inch display in xib
3) setting full screen at launch for window form xib
4) Removing mainwindow.xib and coding tabbarcontroller as the rootviewcontroller of window
EDIT:
Code in appDidFinishLaunching:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setFrame:[[UIScreen mainScreen] bounds]];
// [self tabbar];
self.tabBarController.view.backgroundColor = [UIColor blackColor];
// self.tabBarController.view.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
MainWindow.xib looks like:
Your launch image has the wrong name: Instead of default-568h#2x.png it should be Default-568h#2x.png (note the uppercase D). The file name is case sensitive.
My Bad!..I was using some APIs to show/hide tab bar. Those APIs had hardcoded 480 specified for y.
oopsies!
Related
Inside AppDelegate.m file I have:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.MainVC = [[MainViewController alloc] initWithNibName:#"MainViewController" bundle:nil];
self.HamMenuVC = [[HamMenuViewController alloc] initWithNibName:#"HamMenuViewController" bundle:nil];
self.RevealVC = [[SWRevealViewController alloc]initWithRearViewController:self.HamMenuVC frontViewController:self.MainVC];
self.navC = [[UINavigationController alloc]initWithRootViewController:self.RevealVC];
self.window.rootViewController = self.navC;
[self.window makeKeyAndVisible];
Which is supposed to load my Main VC and then the hamburger menu VC (or slider? in iOS talk), and when I start the app I get the loaded VCs BUT the entire view seems to be shifted down roughly 30 pixels and there's this white space above.
As you can see below, this is the top of my screen and the black is where the MainVC starts:
the top of the screen
I've checked the 'self.view.frame.origin.y' inside the MainVC and it says 0.0 AND I've checked the '[[UIScreen mainScreen] bounds].size.height' and it's giving me the correct height for the device I'm running it on AND I checked the '[[UIScreen mainScreen] bounds].origin.y' and it says 0.0.
Does anyone have a clue why all the data is saying it's in the right place but the fact is it's in the wrong place on my physical device AND on any simulator I choose?
It looks like that's the UINavigationBar on top of the screen. In your code, you're setting your rootViewController with a UINavigationController.
self.navC = [[UINavigationController alloc]initWithRootViewController:self.RevealVC];
self.window.rootViewController = self.navC;
If you need to hide the navigation bar, call this method in your RevealVC's viewDidLoad method:
[self.navigationController setNavigationBarHidden:YES animated:YES];
Also, quick tip, try to name your properties starting with lowercase letters.
my project runs without storyboards, so im loading my view inside AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
self.window.rootViewController = [[SYLoginController alloc] init];
[self.window makeKeyAndVisible];
return YES;
}
It used to work on iPhone 6 sim 9.3 but now, on all simulators it only shows a black screen. But on my iPhone 6 Device it works. Whereas on another iPhone 6 it also shows a black screen. Those two iPhones are literally the same 16gb iPhone 6 bought at nearly the same time.
In SYLoginControllers viewDiDLoad I'm logging the text of one of the buttons. Only on my device it prints the text, on all simulators and the other iPhone it prints (null), so i assume that the xib is not properly loaded.
SYLoginController is a UIViewController, and the related xib holds a UIView with its FilesOwner set to SYLoginController. I really can't see why it only works on this particular device. Also i tried [[SYTabBarController alloc] initWithNibName:#"SYLoginController" bundle:nil], this also does not work...
Did you tried to wrap it arround a Navigation Controller?
SYLoginController *syVC = [[SYLoginController alloc]initWithNibName:#"SYLoginController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] syVC];
self.window.rootViewController = nav;
Also check again if Custom Class is set to SYLoginController in the XIB-File. And the View is connected to the Files Owner.
I'm creating an app without Storyboard on XCode 6.4 and when I run the app, no matter which simulator I use, I always get a (320,480) screen.
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
Ref img: http://i.stack.imgur.com/hGHmt.png
Already tryed:
vc.view.autoresizingMask =
UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
What should I do to make it fill the whole screen?
I had the same problem, You should set launch image of your app about default-568#2x.png with 640 x 1136 pixel size.
More info --> link
Also setting #2x #3x image assest will be good for you.
Add launch screen. It will be solved.
https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/chapters/AddingLaunchImagestoanAssetCatalog.html
I found some sample code.
It show the view by following code in AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification) {
NSLog(#"AppDelegate didFinishLaunchingWithOptions");
application.applicationIconBadgeNumber = 0;
}
AITPreviewViewController *previewViewController = [[AITPreviewViewController alloc] initWithNibName:#"AITPreviewViewController" bundle:nil];
navigationController = [[UINavigationController alloc]initWithRootViewController:previewViewController];
[self.window setRootViewController:navigationController] ;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
The following picture is in the AITPreviewViewController.xib.
But the View is not normal when it run on the iPhone , it show like the following picture.
The three imageView on the top has been obstructing by navigationItem
But when I turn to other View , and use the following code to turn back.
UIViewController *Previewer = [[AITPreviewViewController alloc] initWithNibName:#"AITPreviewViewController" bundle:nil] ;
Previewer.edgesForExtendedLayout = UIRectEdgeNone;
[self.navigationController pushViewController:Previewer animated:YES];
It show the normal View like the following picture.
The View only show not normal at first time...
What happened to this condition ?
Can it use Auto-layout to solve this problem ?
If you don't want to hide navigation bar then in your xib just make a little change
Just change the Top Bar property from none to as shown in image. It will auto place your image below the navigation bar
Try increasing the 'Y' value for those 3 images from your interface builder. Select each image and then go to Size Inspector. There you will see some values. Find the Y value and increase it. This will push the images down.
If you want to show only UI according to "AITPreviewViewController.xib"
Then you can hide your navigation bar.
I am developing a xib-based landscape-only app. The app launches in landscape correctly. However, the view in my main ViewController is presented in portrait. That is, it is rotated 90 degrees so that the image appears cropped and does not take up the entire screen. If I use my interface to present a modal view controller then return to the main ViewController, the issue corrects itself (the view is presented in landscape). This problem did not occur under Xcode 4.2. It occurred after upgrading to Xcode 4.3, and the only code changes that were made were automatically implemented by Xcode when I upgraded the project settings.
Based on advice in other posts, I verified my Info.plist settings for Supported Interface Orientations and Initial Interface Orientation. I overrode the shouldAutorotateToInterfaceOrientation method for each of my view controllers to return YES only for landscape orientations. Also, I turned off auto resizing for the view, as I never want the size/orientation of the view to change.
Based on the ideas in this link [1], I suspected the problem is that the view is not receiving the call to change orientation at launch, possibly due to the removal of the MainWindow.xib concept, which appears to be replaced by the following Xcode-inserted code in AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I modified this method to generate a generic root view controller from which my ViewController class is presented, as shown in the code below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController* myViewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.viewController = [[UIViewController alloc] init];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[self.viewController presentModalViewController:myViewController animated:NO];
return YES;
}
Voila! This solved my problem. However, to me it feels like a change at a fundamental level, which I don't want to make at this point in my development. What I intended to be my root view controller is now a modal view. Does anyone have another solution to this issue?
Thanks in advance!
I had this same issue: an app which was meant to be in Landscape that assumed the ViewController was always in Portrait. I made tons of changes to every aspect of the project and info.plist, including giving the main UIWindow a root-view controller which was landscape. It still didn't work. I eventually undid all the changes and just added the two lines noted below to my app delegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[_window addSubview:[_viewController view]];
glView = _viewController.glView;
// THIS FIXED ORIENTATION FOR ME IN IOS 6
_window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// END
...my other setup code here...
}
Nothing else was necessary.
It appears that, for some reason, in iOS 6 the UIWindow root-view-controller setting is sometimes ignored in Interface Builder. I am sure my reasoning is wrong somewhere, but I thought this might well help prod someone in the direction of a fuller, more exhaustive answer.
In iOS 8, settings windows frame to the UIScreen is also necessary, as it won't get automatically updated.
self.window.frame = [UIScreen mainScreen].bounds;