Shake detection with using IBuilder or Load View without IBuilder [duplicate] - iphone

This question already has answers here:
iPhone Shake event not properly working
(2 answers)
Closed 2 years ago.
I am writing some application (let's say game - 1 view no cocoa controls) which needs to detect shakes.
As beginner with IOS have started with default openGL template (new one). Application works.
I have decided to add shakes. "motionBegan" don't work on "EAGLEview", so I have created view controller. Touches worked but "motionBegan" still not worked. (same like "viewDidAppear")
I thought that somehow IBuilder file is overlapping it.
So I have decided to resign from my IBuilder file and move forward without.
What I have now is:
main.m
int retVal = UIApplicationMain(argc, argv, nil, #"SimplePianoAppDelegate");
SimplePianoAppDelegate.m
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:YES];
viewController = [[InputControler alloc] init];
glView=[[EAGLView alloc] initWithFrame:window.bounds];
glView.hidden=NO;
viewController.view=glView;
[window bringSubviewToFront:glView];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
[glView setMultipleTouchEnabled:YES];
[glView performSelectorOnMainThread:#selector(mainAppLoop) withObject:nil waitUntilDone:NO];
With this code touches and motions worked but I don't see anything. (just white screen) :(
I am sure that some of the lines above are not necessary, but I am trying all possible options. What is strange is that no matter if I create my glView or not "loadView" in viewcontroller is not called.
Thank you for help in advance.
Mariusz

while I have connected view outlet in view with controller it started to work... with this:
[self becomeFirstResponder]

Related

How to remove from this Debugger warning [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Getting “Using two-stage rotation animation” warning with UIImagePickerController
In my iphone app i have a login screen after loging in i am navigating to a class ( i have tab barcontroller with 5 tabs here)
like this i am programmatically creating the tabbar
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *arrControllers = [[NSMutableArray alloc] initWithCapacity:5];
//Add PunchClock to tab View Controller
PunchClock* objPunchClock = [[PunchClock alloc] initWithTabBar];
NavigationController = [[UINavigationController alloc] initWithRootViewController:objPunchClock];
NavigationController.navigationBar.tintColor = [UIColor brownColor];
[arrControllers addObject:NavigationController];
[NavigationController release];
[objPunchClock release];
tabBarController .viewControllers = arrControllers;
[arrControllers release];
[self.view addSubview:[tabBarController view]];
after logging in while navigating to this class i am getting this Debugger warning
2012-07-07 12:09:27.988 WorkForce[1475:207] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
2012-07-07 12:09:28.074 WorkForce[1475:207] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate
what is it mean,,,how to remove this warning? please help me out
I have no idea what that error message means but when you get such a specific error message, it is often helpful to do a search with the entire error message in quotes to see if anyone else has encountered it.
Apparently they have. Please report back and tell us what it means.
The two-halves animation methods like willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: and willAnimateSecondHalfOfRotationToInterfaceOrientation:duration: are an older approach. If you've implemented these methods, they should be removed so that the one-step scheme (in this case, willAnimateRotationToInterfaceOrientation:duration:) can be used.

ViewController screen to download database before launch application

I used the storyboard to create my application, where the initial View is an TabBarController.
But the first time the application starts I download the database (4Mb). So, my splash screen is displayed until the download is over, because the download is done in AppDelegate. I would like to change it and display a View to the user indicating that a download is being done, not to get the impression that the application crashed.
I tried this in didFinishLaunchingWithOptions: but doesn't work:
LoadViewController *loadView = [[LoadViewController alloc] init];
[self.window makeKeyAndVisible];
[self.window addSubview:[loadView view]];
Thanks in advance.
I am not sure if this will meet your needs but I used MBProgressHUD to handle some display while uploading data to a server, maybe you could do something like the same with your download of the database.
HUD = [[MBProgressHUD alloc] initWithView:[self view]];
[[self view] addSubview:HUD];
HUD.dimBackground = YES;
HUD.delegate = self;
[HUD showWhileExecuting:#selector(taskToDownloadDatabase) onTarget:self withObject:nil animated:YES];
This would allow you to show the user some progress that something is happening and when the database is fully downloaded initialize your view.
Why not download the database outside the appDelegate, then share it with the appdelegate? Or Perhaps do:
[self performSelector#selector(downloadDatabase) afterDelay:1...];
so the view loads first?

Problem with getting a modalViewController to appear

I've been fighting with this for hours. I've searched around everywhere and just can't seem to find the solution to my problem. I'm pretty sure I'm just lacking some key concepts here.
My AppDelegate (didFinishLaunching) basically sets up my window and invokes RootViewController:
// create our window
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setBackgroundColor:[UIColor blackColor]];
// create our rootviewcontroller
RootViewController *controller = [[RootViewController alloc] init];
// add our rootviewcontroller's view to our window
[window addSubview:controller.view];
// controller is now owned by window's view
[controller release];
// show us to the world
[window makeKeyAndVisible];
When I add controller.view as window's subview, my understanding is that RootVC's loadView will automatically get called.
In RootVC loadView, I create a tabBarController, each tab having a navigationController and it's own viewController. All that is working fine.
In RootVC viewDidLoad, I'm checking to see if this is the first time a user is running this app, and if so, I want to throw up a modal welcome screen. This is the part I'm having trouble with.
I'd like to keep as much code out of the RootVC's viewDidLoad method, and ideally would be able to accomplish what I want with this:
WelcomeViewController *welcome = [[WelcomeViewController alloc] init];
[self presentModalViewController:welcome animated:true];
[welcome release];
Obviously this isn't working. WelcomeVC's loadView hasn't been run yet because I haven't explicitly set it's view property. I've played around with a bunch of different solutions (welcome.view - [[UIView....], using WelcomeVC's init method to set self.view) but I just can't seem to get that modal to pop up.
How should I accomplish what I'm looking for? What are the best practices, and what's the best solution to keep my code tight and tidy?
I'm stuck, so hopefully your solution will allow me to continue developing my app!
Although the problem is not so simple, the solution is. You have to wait until the main view appears. So check the condition and present your modal view in viewDidAppear method, not in viewDidLoad method.

How can I display a introduction modal view when the app start up?

I have a tab bar application and I want to display those views that most part of apps have, with the name of the company or the name of the app.
I've created the follow viewController
Introduction *introducao = [[Introduction alloc] initWithNibName:#"Introduction" bundle:nil];
I don't know where exactly should I insert the code to show the modal because I have a tab bar application:
[self.navigationController presentModalViewController:galeria animated:YES];
I've tried to insert these lines on appDelegate.. but didn't work.. somebody have an idea?
if you are trying to show a splash screen right when the application opens, you should use a Default.png image instead of a view controller showing an image. Check out the Apple Documentation on Human Interface Guidelines and Beginning iPhone Development.
First of all, you'll need to ensure that you have a navigation controller present to present the model view from. Otherwise in the above code you'll be messaging nil and nothing will happen. Then you'll want to put the presentModalViewController:animated: call in your app delegate's applicationDidFinishLaunching: implementation.
Thanks for all answers.. they were very useful to understand better the process..
I have found a solution that does exactly what I need! So if someone need to create those splash screens with a sequence of images it is very useful:
Just create a ImageView on the Delegates Header and do the following:
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:#"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
to control the duration of the splash screen:
[self performSelector:#selector(removeSplash) withObject:nil afterDelay:1.5];
To remove the splash:
-(void)removeSplash;
{
[splashView removeFromSuperview];
[splashView release];
}
so If you want to create a sequence of image just create a method to change the splashView.image.. and create a NSTIMER to call it..

iPhone Adding Views on Windows Practice

I'm learning how Objective-C on the iPhone layers views onto the main window.
I've tried remaking a basic program to draw two different colored rectangular views onto the main UIView for an app, but it does not seem to work.
My current output is a white screen. However, when I close the application, it briefly shows the two rectangles as they're closing, making me believe they're drawn but not displayed for some reason.
Assuming the psuedo-code below (shortened from the original documentation for the sake of StackOverflow, but copied directly into my project) is fine, what else might I have to do to my project to get these rectangles to display?
Code from Apple in my TestAppDelegate.m file:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create the window object and assign it to the
// window instance variable of the application delegate.
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.backgroundColor = [UIColor whiteColor];
// Create and initialize a simple red square
// Create and initializesimple blue square
// Add the square views to the window
[window addSubview:redView];
[window addSubview:blueView];
// Once added to the window, release the views to avoid the
// extra retain count on each of them.
[redView release];
[blueView release];
// Show the window.
[window makeKeyAndVisible];
}
Link to Original in Apple Docs: http://tinyurl.com/y8alvgt
You may need to call setNeedsDisplay on the window
[window setNeedsDisplay];
this has the effect of telling CocoaTouch that your window contents have changed and need to be redrawn.
Here's a link to the documentation.