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
Related
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 avoiding using NIBs completely. I'm getting problems on iOS 7.1, but not on iOS 8.x.
iOS 7 vs. iOS 8
The code looks like this in the UIResponder <UIApplicationDelegate>
- (void) setupViewController {
CGRect frame = UIScreen.mainScreen.bounds;
self.window = [[UIWindow alloc] initWithFrame:frame];
self.window.backgroundColor = UIColor.whiteColor; // viewController's view is green
ViewController *viewController = [[ViewController alloc] init];
UIView *view = [[UIView alloc] initWithFrame:self.window.bounds];
viewController.view = view;
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self setupViewController];
return YES;
}
I've also tried some methods dealing with iOS 8, but even settings the UIWindow frame to 5000, 5000 produces the same results.
[I've seen a number of related questions and tried out the suggestions, but to no avail, including flipping the bounds if it's iOS 8, etc. etc.]
The problem is that you don't have a launch image for the 4-inch screen, so the iPhone 5s is treating this app as a 3.5-inch app (iPhone 4) and letterboxing it.
i am developing app using ios8 support with portrait and Landscape mode both,
but problem is that when i try to rotate my Device to Landscape mode it cant work for me.
i test same thing in my other device iPhone 4 with ios7.1.2 it work fine but not working with ios 8.1 in iphone 4s
please give me suggestion if any one also have the same problem.
ARViewController* metaioCloudPlugin = [[ARViewController alloc] initWithNibName:#"ARViewController" bundle:nil];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = metaioCloudPlugin;
[self.window makeKeyAndVisible];
====
This is my AppDelegate code for main window root view.
Thanks in advance.
i fixed this issue .
Remove below line from code and its work fine now.
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
refer this link
iOS 8 - App not rotating appropriately
I was facing the same issue, while I was updating the xib base project for iOS8,
I found the solution inside your question,
thanks for asking :)
self.window.rootViewController = loginScreen;
While navigating to the screen
loginScreen = [[LoginScreen alloc] initWithNibName:#"LoginScreen" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:loginScreen];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = loginScreen;
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
This tutorial gives you a simple and nice horizontal UITableView
but when removing MainWindow_iPhone.xib (_iPad) and create UIWindow object programmatically in the app delegate, the horizontal table and contents (image and label) become unstable, its size changed and scroll doesn't work properly. Also, labels become hidden when scroll up.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// self.window = [[UIWindow alloc]ini];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
// self.window.contentMode = UIViewContentModeScaleToFill;
// self.window.opaque = NO;
// self.window.clipsToBounds = NO;
// self.window.clearsContextBeforeDrawing = NO;;
// self.window.autoresizesSubviews = YES;
// self.window.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
ArticleListViewController_iPhone *masterViewController = [[[ArticleListViewController_iPhone alloc] initWithNibName:#"ArticleListViewController_iPhone" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
I already tried all window properties that affect size with no success. If I remove my code and set MainWindow_iPhone as Main Interface, all things work well.
Also, I tried the following:
Clean & Build
Option & Clean & Build
Reset simulator
Another version of xCode
Another version of Mac os
Test on device
What the problem, Do you have any suggestions?
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!