Unable to add subview to OF view (following iPhoneGuiExample)

I am trying to add an iOS subview to the OF view and have been following the model given in the iPhoneGuiExample. The app builds but stops at the line ‘UIApplicationMain(nil, nil, nil, [NSString stringWithUTF8String:appDelegateClassName.c_str()]);’ and gives the error message ’ terminating with uncaught exception of type NSException’. I did something quite similar in an app I did two years ago using OF 074 without a problem. Here are the pertinent parts of my code:


#include "ofApp.h"
#include "ButtonView.h"

ButtonView * buttonView;

void ofApp::setup(){

    buttonView = [[ButtonView alloc] initWithNibName:@"ButtonView" bundle:nil];
    [ofxiPhoneGetGLParentView() addSubview:buttonView.view];



#import <UIKit/UIKit.h>
#include "ofApp.h"

@interface ButtonView : UIViewController <UIGestureRecognizerDelegate> 

- (void) viewDidLoad;



#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ButtonView.h"
#include "ofxiOSExtras.h"

@implementation ButtonView

// app pointer
ofApp * myApp;

- (void) viewDidLoad {
    // get app pointer
    myApp = (ofApp*)ofGetAppPtr();


I’m using XCode 6 and attempting to run on both an iPhone 5 simulator and an iPad Mini with the same results.

did you figurate out?

I created an example project based on @RonH code and worked for me.
see the example here

@joreav No, I didn’t. For a variety of reasons I decided to do everything natively. But Dorald’s example works for me. It looks like one mistake I might have made was to say [ButtonView alloc] instead of [ViewController alloc]?

@Dorald Thanks for the input.

Hey! @dorald im trying to implement the code in storyboard app.
I got it working but i only see the native view im not sure how to implement this part

//// In a storyboard-based application, you will often want to do a little preparation before navigation
//- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// // Get the new view controller using [segue destinationViewController].
// // Pass the selected object to the new view controller.

can you help me with this? thanks…