iDevGames Forums
Moving away from xib\nib - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Moving away from xib\nib (/thread-1410.html)

Moving away from xib\nib - kendric - Apr 22, 2009 07:45 PM

So I wanted to ditch xib\nib files because I am unable to detect touches under the status bar even though its invisible, and I read somewhere that you need to not use a xib\nib to get that to work. First off if anyone can confirm that, that would be great.

So here is what I did(note project based off of sample opengl project in xcode:

//In main changed the last 2 args from nil nil to:
int retVal = UIApplicationMain(argc, argv, @"UIApplication" , @"MyAppDelegate");

//in my app delegate applicationDidFinishLaunching added

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
window.backgroundColor = [UIColor whiteColor];  
[window makeKeyAndVisible];  
glView=[[EAGLView alloc] initWithFrame:rect];

[window addSubview:glView];

//In my EAGLView class duplicated constructor initWithCoder to
    if((self = [super initWithFrame:rect]))
        // Get the layer
        CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
        eaglLayer.opaque = YES;
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
        context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
        if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer])
            [self release];
            return nil;
    return self;

While this gets my gl view on the screen, it is highly not how its supposed to look. It seems zoomed in for one, and there is a large blank area on the left side.
Does anyone have any experience with doing this?

Moving away from xib\nib - Frank C. - Apr 22, 2009 09:03 PM

To fix your code, just use UIScreen bounds for the everything - that made-up rect is rotated.

[EDIT]: This won't fix your touch problem though - that's a bug in the simulator - the device should work fine.

Moving away from xib\nib - kendric - Apr 22, 2009 10:16 PM

You were right about both things. THanks.