Jump to content
  • Advertisement
Sign in to follow this  
taby

iOS touchedEnded not called

This topic is 666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I started getting this exception thrown by my app: Application windows are expected to have a root view controller at the end of application launch.

 

So I added this code to the didFinishLaunchingWithOptions function:

for(UIWindow *win in windows)
{
    NSLog(@"Window: %@", win.description);
 
    if(win.rootViewController == nil) 
    {
        UIViewController* vc = [[UIViewController alloc]initWithNibName:nil bundle:nil];
        win.rootViewController = vc;
    }
}

Except now, touchesEnded is not called. Do you know why not? It worked fine up until a while ago when the exceptions started happening. If it helps to know, I am using NeHe's iOS Lesson 2 as the base for my app.

 

My touchedEnded code is like such:

- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
{
    NSLog(@"TouchesEnded");
    UITouch* touch = [touches anyObject];
    CGPoint location  = [touch locationInView: self];
    lesson->touch_up_pos(location.x, location.y);
}
Edited by sjhalayka

Share this post


Link to post
Share on other sites
Advertisement

Your approach of randomly jamming generic UIViewControllers into every window makes no sense. But to the point, the root view controller you set is the one that receives touchesBegan/Moved/Ended. I don't know where you were receiving those functions previously, and NeHe's lesson 2 is ancient. Can't imagine it's even close to up to date with current iOS practices. From my experience, you should probably just start over with a storyboard based iOS template.

Share this post


Link to post
Share on other sites

I am a fairly long time iOS app builder and Swift is such an amazing and more efficient method of creating apps. There will be some learning curve, and a few things that are not the greatest (in swift 3.0 they removed ++), but the Pros out weight the cons by a vast margin.

I think you will find making new apps more fun and faster.

Share this post


Link to post
Share on other sites

The Nehe iOS code is not really a good starting point.  It was written as an Xcode 4 project We are now on Xcode 8).

The warning you are getting is because your application doesn't have a root view controller because the Nehe code actually just sticks the glview directly as a subview of the window.  This is an old OSX way of doing things and has never been the correct way of doing things in iOS.

The correct fix would be to delete the xib file and create a new one that has a viewController with the glView as its main view.

You would probably be a lot better off just starting from scratch using Swift and GLKit as a starting point and following modern up to date iOS best practices.

 

 

I prefer C++.

 

 

This doesn't make sense as the Nehe code and the code that you have shown is not C++ but, is Objective C.

Share this post


Link to post
Share on other sites

You would probably be a lot better off just starting from scratch using Swift and GLKit as a starting point and following modern up to date iOS best practices.

 

Agree.

Share this post


Link to post
Share on other sites

...

 

You can mix C++ code in with Objective C projects. That's how I did my OpenGL ES 2.0 camera, all C++. Right?

 

Thank you for the tip with the xib file. I'll give that a shot.

Edited by sjhalayka

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!