Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-14-2009, 03:39 AM   #1 (permalink)
Johanovski
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
Johanovski is on a distinguished road
Default Unable to link my OpenGL app with the iPhone interface!

Hi there!

I'm trying to integrate the iPhone Interface (a UITextField in my case) to and OpenGL app I've done (everything's almost done, but the name entry system for the scores) but I'm unable to do such that (I suppose) trivial thing!
I've never developed using the iPhone Interface (always worked in OpenGL) and I've followed the Apple's iPhone Dev Center Tutorial for the iPhone SDK (a "Hello world" with a UITextField -bingo!-, a UILabel and a UIButton). In the tutorial, as always, everything looks easy, intuitive (more or less), and everything worked well. But, back to real life, integrating my existing app with the Interface is not as trivial as I hoped to be...
I have an OGLGameAppDelegate, a EAGLView, and I've created a myViewController class (where I want to add the UITextField). I don't know if this last class is necessary or if I can use the EAGLView class to add the UITextField, but the EAGLView hasn't got a NIB file, so I've decided creating a new "layer" to add there the Interface elements.
What I have in the OGLGameAppDelegate and in the myViewController is:

************************************************** **********
// OGLGameAppDelegate.h
#import <UIKit/UIKit.h>

@class EAGLView;
@class MyViewController;

@interface OGLGameAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
EAGLView *glView;
MyViewController *myViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet EAGLView *glView;
@property (nonatomic, retain) MyViewController *myViewController;

@end
--------------------------------------------------------------------------------
// OGLGameAppDelegate.m
#import "OGLGameAppDelegate.h"
#import "EAGLView.h"
#import "MyViewController.h"

@implementation OGLGameAppDelegate

@synthesize window;
@synthesize glView;
@synthesize myViewController;

- (void)applicationDidFinishLaunching: (UIApplication * )application {

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

MyViewController *aViewController = [[MyViewController alloc]
initWithNibName:@"MyViewController" bundle: [NSBundle mainBundle]];
[self setMyViewController:aViewController];
// Tambe podria ser --> self.myViewController = aViewController;
[aViewController release];

glView.animationInterval = 1.0 / 60.0;
[glView startAnimation];
}


- (void)applicationWillResignActive: (UIApplication *)application {
glView.animationInterval = 1.0 / 5.0;
}


- (void)applicationDidBecomeActive: (UIApplication *)application {
glView.animationInterval = 1.0 / 60.0;
}

- (void)applicationDidReceiveMemoryWarning: (UIApplication *)application {
NSLog(@"***** MEMORY WARNING *****");
[glView warning];
//[glView alliberaMemoria];
}


- (void)dealloc {
[myViewController release];

[window release];
[glView release];
[super dealloc];
}

@end

--------------------------------------------------------------------------------
// myViewController.h
#import <UIKit/UIKit.h>


@interface myViewController : UIViewController <UITextFieldDelegate> {
UITextField *textField;
}

@property (nonatomic, retain) IBOutlet UITextField *textField;

@end
--------------------------------------------------------------------------------
// myViewController.m
#import "myViewController.h"


@implementation myViewController

@synthesize textField;

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == textField) {
[textField resignFirstResponder];
}
return YES;
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}


@end
************************************************** **********

And, in the myViewController.xib file, I've created a UITextField named "textField", linked it's "delegate" to "File's Owner" (which is of myViewController class), linked it's "textField" to "File's Owner", and linked the File's Owner "textField" to "textField", the "view" to "View", and the "delegate" to "textField".
I don't know exactly how it works, but I've done the same I've done with the "Hello world" example...

However, when I try to compile, XCode gives me an error:
************************************************** **********
Link /Volumes/(...)
".objc_class_name_MyViewController", referenced from:
Literal-pointer@__OBJC@__cls_refs@MyViewController in OGLGameAppDelegate.o
Symbol(s) not found
Collect2: Id returned 1 exit status
************************************************** **********

Can anyone help me with this? It's getting me mad as seconds pass...

Thanks in advance! :)
Johanovski is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,389
Threads: 94,004
Posts: 402,463
Top Poster: BrianSlick (7,978)
Welcome to our newest member, HenryCLacey
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.