It's not a question about code, it's possible? because i have a project with many view and testing is not to fast.
You could set a different view in your root controller at
-applicationDidFinishLaunching:withOptions:
its possible but in some view you will get problem because your some view based on those view which are't loading.
by the way here is code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.YourviewController = [[[self.YourviewController alloc] initWithNibName:#"self.YourviewController" bundle:nil] autorelease];
self.window.rootViewController = self.YourviewController;
[self.window makeKeyAndVisible];
return YES;
}
Related
I asked the same question before for the some but now i changed the way to implement my tab bar i have this view
i want when i push a button it will make a tab bar composed in 5 buttons the some that i can choose it in the first view
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
AcceuilViewController *viewController =[[[AcceuilViewController alloc]
initWithNibName:#"AcceuilViewController" bundle:nil]autorelease];
self.navController = [[[UINavigationController alloc]initWithRootViewController:viewController]
autorelease];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
return YES;
}
Create your UITabBarController as per normal. When a user touches a button, push to that controller:
YourTabController *tabController = [[YourTabController alloc] initWithNibName:#"Tabs" bundle:nil];
[self.navController pushViewController:tabController animated:YES];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I do not know what is wrong with this method.I just created a new project and run it.It showing Applications are expected to have a root view controller at the end of application launch
If you have a MainWindow.xib.
remove below line. do not remove MainWindow.xib
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
OR
do not remove above line. remove MainWindow.xib and Project Summary Main Interface set null.
- (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;
}
Hi when using autolayout on iOS 6, my "rootView" of my rootViewController doesnt seem to resize properly if at all.
My rootViewController is loaded from a nib and i am adding it to the view-hierarchy like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
RootVC *rootVC = [[RootVC alloc] initWithNibName:#"RootVC" bundle:nil];
self.window.rootViewController = rootVC;
return YES;
}
But when i rotate the simulator the view of rootVC doesnt resize. Since you cant set any constraints to the "rootview" in a xib, I also tried this but without any effect:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
RootVC *rootVC = [[RootVC alloc] initWithNibName:#"RootVC" bundle:nil];
self.window.rootViewController = rootVC;
NSArray *vConst = [NSLayoutConstraint constraintsWithVisualFormat:#"V:|[view]|" options:0 metrics:nil views:#{#"view" : rootVC.view}];
NSArray *hConst = [NSLayoutConstraint constraintsWithVisualFormat:#"H:|[view]|" options:0 metrics:nil views:#{#"view" : rootVC.view}];
[self.window addConstraints:vConst];
[self.window addConstraints:hConst];
return YES;
}
When i log-out the frame-size of the rootvc's view, it's always the portrait-format (w:768, h:1024)
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
NSLog(#"%f, %f", self.view.frame.size.width, self.view.frame.size.height);
}
could someone please tell me what i'm missing here? i've wasted hours with this problem and got nowhere^^
thx
It seems that a lot of things can go wrong with the autolayout feature iOS 6. Ambiguities in the constraints and failing to disable the translatesAutoresizingMaskIntoConstraints in your view controllers can cause much conflict. So ensure there is no ambiguities in the constraints by calling the autolayoutTrace method in lldb: po [[UIWindow keyWindow] _autolayoutTrace]
If there are ambiguities, you must resolve them.
I need to show another view from rootviewcontroller on button click. I have written the following code but it doesnt work. Any ideas why?
In my app delegate method i have the following code -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[MainMenuViewController alloc] initWithNibName:#"MainMenuViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Then in my mainviewcontroller i have a button action which is supposed to take me to a different class but it does nothing. Although the button action is working since nslog statements work. Any ideas?
LoginViewController * loginViewController = [[LoginViewController alloc]initWithNibName:#"LoginViewController" bundle:nil];
[self.modalViewController presentModalViewController:loginViewController animated:YES];
NSLog(#"HE::P");
If you try :
[self presentModalViewController:loginViewController animated:YES];
I have ViewController(Passwordviewcontroller) which I want to show with "presentModalviewController"
I have an AppDeleage:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Here is My ViewController from which I want the PasswordviewController to show:
-ViewDidLoad
{
self.passwordView = [[PasswordView alloc]initWithNibName:#"PasswordView" bundle:nil];
[passwordView setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:passwordView animated:YES];
}
I tried everything but its still not working, has somebody an Idea?
Put this in viewDidAppear instead of viewDidLoad. In viewDidLoad your view might be loaded into memory but doesn't have to be on-screen yet. In viewDidAppear on the other hand your view is ready to be shown an properly inserted in the window in such a way that you may show modal views.
Edit: Changed viewWillAppear to viewDidAppear as per comments