I have iOS 6 app and I'd like to add one more ViewController (storyboard) in which it would be augmented reality. Now, I'm using Mixare, and I could start AR, but cannot exit the view.
I used this tutorial for implementation Mixare as library into my project.
I think that problem is that I'm calling MixareAppDelegate
MixareAppDelegate *delegate = [[MixareAppDelegate alloc] init];
[delegate runApplication];
that uses self.window.rootViewController
self.window.rootViewController = augViewController;
After that, I can close view, but app freezes. Is there anywhere tutorial how to call Mixare as one view in storyboard with navigation?
Is there easy way to call MixareAppDelegate which is a ViewController as viewController not as element in window.rootViewController?
You can only interact with one window at a time.
When you have added the MixareAppDelegate's window then previous window get invisible for further interaction. You have to visible previous window again.
try:
[window makeKeyAndVisible];
it will solve all of your issues.
Related
I have two views, when that app loads if the prefs match the users log in I am trying to load the next ViewController immediatly.
Each view normally shows in landscape and I have set the apps settings to only allow landscape. However when I try to load the second view immediatly from the first view "viewdidload" The second view appears on its side.
This is what my code looks like, this code is in a method that gets called from the first viewcontrollers viewdidload
currentProjectListViewController = [[CurrentProjectListViewController alloc] initWithNibName:#"CurrentProjectListViewController" bundle:nil];
[currentProjectListViewController setDelegate:self]; // set the delegate so it can access the returning method to update the view
UIWindow* keyWindow= [[UIApplication sharedApplication] keyWindow];
[keyWindow addSubview: currentProjectListViewController.view];
[self presentViewController:currentProjectListViewController animated:NO completion:nil];
I have no idea where to even start with this. it makes it to the second views viewdidload how ever like I say the view appears to be correct but its just on its side effectivly 90degrees incorrect.
any help making sure this apperar in landscape would be greatly appreciated.
I think your View hierarchy is somewhat wrong.
Why are you adding view of currentProjectListViewController to UIWindow object and immediately after adding it as subview you are presenting it using presentViewController from the current ViewController?
When you load and show the second ViewController, your presentViewController code should work.
You dont need to play with your UIWIndow object. Just make sure you dismiss your present view controller so as to reduce memory footprint and memory leaks.
Background and Aim:
In my existing app, I'm trying to provide voice messaging feature to user. The idea is to optionally provide universal access of voice messaging from anywhere in the app to the user (inspired by facebook messages). I have had partial success so far in displaying my mini message dashboard and tap on which opens customized message (popover) view on both iPhone & iPad.
I added my mini dashboard subview on application keywindow and hence it's visible across (top of) all the views when navigating within the app.
[application.keyWindow addSubview:self.messageDashBoardVC.view];
This made it appear automatically (out of the box) on top of even the modal dialogs (mostly) in app presented like this..
[self presentViewController:modelVC animated:YES completion:nil]
Specific PROBLEM statement:
However..
On iPad when a view controller is presented modally with
modalPresentationStyle = UIModalPresentationFormSheet
or UIModalPresentationPageSheet
the mini dashboard hides behind the modal dialog (sheet). HOWEVER, I want user to access voice feature (mini dashboard & popover views) when working on these sheets.
My existing app uses a lot of such modal dialogs (sheets).
General Problem statement:
Is there any reusable component/source code available that does same thing because I think the orientation handling will also be a tricky/quite a work with my approach? Any other problem that you envisage with my approach?
I found some success to specific PROBLEM statement above:-
The modal view is presented (added) to the same window so I simply brought my mini dashboard view in front like this..
UIWindow *appDelegateWindow = [[[UIApplication sharedApplication] delegate] window];
UIView *miniView = (UIView *)[appDelegateWindow viewWithTag:12221]; // 12221 is tag of mini dashboard view.
[appDelegateWindow bringSubviewToFront:miniView];
However, I'm still looking forward to your expert opinion about my approach and open for alternative approach considering orientation and other potential challenges I might get with this approach.
Next up - I am working on bringing my custom popover view in front of modal sheet. As of now, tap on mini view opens the message popover but behind the modal sheet.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MALoginViewController *login=[[MALoginViewController alloc]initWithNibName:#"MALoginViewController" bundle:nil];
MANowPlayingViewController *nav=[[MANavigationController alloc]initWithRootViewController:home];
[self.window setRootViewController:nav];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
here MANowPlayingViewController is class of UINavigationController..so you have to create separate class for UINavigationController...then set that into Window RootviewController..
whatever you give in that UINavigationController class will display all pages in your app..you can handle your all common codes inside this class..For example if you add UIButton on that NavigationBar ,it will display in all classes...
thanks..
I am learning iPhone development and in my application I have some view but I should use a window, so I want to call a window in an IBaction how can I call a window? I try to use the example with AppDelegate you can see my code :
- (IBAction)start:(id)sender {
self.window = [[[Game1ViewController alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window makeKeyAndVisible];
}
Game1ViewController is type UIWindow.
Best Regards
I believe your app only gets one window. On top of this you place different views. These can be anything that subclasses UIView. These can be controlled by a UIViewController. Usually there is some sort of design style that dictates how the app is structured, between UINavigationController, UITabController, Master/detail.
If you open Xcode and start with one of their templates such as master/detail you can see the transitions between views and how to make one appear/disappear and the interaction between view and view controller .
I have copied some files from a very small (and working) project to a bigger Xcode project.
In particular I have copied a xib file (with just one UIView subclass element), the UIView subclass, and ViewController.
The smaller project simply draws a color background and draws circles as long as the user touches the screen.
I have adapted the code of the bigger project so that at the beginning it loads the xib file. I have added this to the AppDelegate so that it loads the new xib instead of the old one.
(see edit #1 for more details)
Even if drawRect is called (I've tested adding NSLog) nothing is shown[*]. Moreover if I click on the screen of the simulated iPhone the app crashes.
int retVal = UIApplicationMain(argc, argv, nil, nil);
Program received signal EXC_BAD_ACCESS
I am not sure where the problem lies so please let me what I can post.
I have Xcode 4 and I am working with iOS 5.
Thanks for your help. I hope this question is not too naive.
EDIT #1:
This is my xib with a list of classes. I am trying to edit the source code for a Jabber Client that I have found here inserting my own views.
I cannot post image but this is the link
http://i.stack.imgur.com/gDsNb.png
The class CircleDrawer is handling touches and drawing circles.
The class MTViewController is sending a test message.
The class JabberClientAppDelegate (basically unchanged from the downloaded code), connects to the server and authenticates the user. What I have changed is this method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[MTViewController alloc] initWithNibName:#"MTViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
/*
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;*/
}
EDIT #2:
I am starting from scratch.
I am trying to rebuild the app but I get a crash. I have started another discussion since it is not directly relevant to this problem.
EXC_BAD_ACCESS right after touchesBegan
[*]: if I simulate pressing the home button for an instant I can see the background color (then of course I don't see anything else because the simulator returns to the springboard).
Check your MainWindow.xib.
Add appDelegate object below your window (in xib).
Set your class property for appDelegate object to your own appdelegate class.
Then your window object should be connected to appdelegate object's window property.
Now in codebase create object of your viewController class and add subview to window.
Hope this steps will give you some idea about code.
I guess you must have already followed all these steps.
I had the entire app (it consists of one view) set up and ran from a View in the ViewController object of the MainWindow nib, INSTEAD of actually having the view ran from the actual ViewController nib.
The app runs flawlessly, however I have two warnings. I learned that these warnings are caused by me running everything from the MainWindow nib rather than a ViewController.
Are there any issues with running an app from the MainWindow rather than an actual ViewController? The app is text based and involves constantly updating UILabels. You can find it here if you'd like to take a look at what I'm talking about.
Right now having it set up this way causes no issues... however I am planning on expanding the app. I tried copy and pasting my Scroll View to the actual view controller nib, but when I did I just had a grey screen. Can I leave the app as it is?
But what is there in your MainWindow.xib file? If you just want to have window object, go to your applicationDidFinishLaunching method and create a window object.
- (void)applicationDidFinishLaunching:(UIApplication *)application{
UIWindow *appWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = appWindow;
[appWindow release];
}
Or you could have select the option Window-Based application while creating a new project.