SIGABRT when loading xib / nib file on iPad

Hey all

I’m trying to adapt Theo’s iPhone GUI example for the iPad, but I’m not having much fun.

So far I’ve managed to get the existing xib file to full iPad resolution by hacking the .xib file with TextMate to change the resolution from 320 480 to 768 1024. That gave me extra canvas space in the Interface Builder to play around, but you cant get splitview up and running.

So I wanted to start a new xib file. I made a new file and replaced the old one in my project. But now when I try to open the xib file at

  
	[ofxiPhoneGetUIWindow() addSubview:myGuiViewController.view];  

I get a SIGABRT message…

#7 0x33b04e48 in std::terminate
#8 0x33b04f18 in __cxa_throw
#9 0x333736aa in objc_exception_throw
#10 0x31597c74 in +[NSException raise:format:arguments:]
#11 0x31597d3e in +[NSException raise:format:]
#12 0x30201280 in -[UIViewController _loadViewFromNibNamed:bundle:]
#13 0x30161180 in -[UIViewController loadView]
#14 0x301592c6 in -[UIViewController view]
#15 0x0000648c in testApp::setup at testApp.mm:22

So it seems to be having trouble getting myGuiViewController.

i cant find any reference to myGuiViewController in Interface Builder. The only reference that I can find is to “MyMusicView” which is set as the Class for File Owner. But I cant see that anywhere in XCode so I guess that doesn’t matter too much.

So my guesses are that either:
* There’s a reference name that ‘addSubView’ is looking for which isn’t in my new file
* There’s a type of something in ‘addSubView’ that isn’t available in the xib file
* The xib file is somehow the wrong format

my xib file contains
‘file’s owner’, ‘first responder’ and ‘view’

I’ve tried a blank iPhone xib, but that gives the same error.

I cant seem to connect ‘New Referencing Outlet’ of View to File’s Owner
so i think that’s where i’ll start…

elliot

If I open up Theo’s xib file (i think it’s theos, i saw his name on this example somewhere. sorry if i’m misplacing credit!)
and inside there’s reference to the MyGuiView class and to the .h file:

  
  
				<object class="IBPartialClassDescription">  
					<string key="className">MyGuiView</string>  
					<string key="superclassName">UIViewController</string>  
					<object class="NSMutableDictionary" key="actions">  
						<bool key="EncodedWithXMLCoder">YES</bool>  
						<object class="NSArray" key="dict.sortedKeys">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<string>adjustPoints:</string>  
							<string>backgroundTouch:</string>  
							<string>fillSwitch:</string>  
							<string>hide:</string>  
							<string>keyboardDone:</string>  
							<string>less:</string>  
							<string>more:</string>  
						</object>  
						<object class="NSMutableArray" key="dict.values">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<string>id</string>  
							<string>id</string>  
							<string>id</string>  
							<string>id</string>  
							<string>id</string>  
							<string>id</string>  
							<string>id</string>  
						</object>  
					</object>  
					<object class="NSMutableDictionary" key="actionInfosByName">  
						<bool key="EncodedWithXMLCoder">YES</bool>  
						<object class="NSArray" key="dict.sortedKeys">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<string>adjustPoints:</string>  
							<string>backgroundTouch:</string>  
							<string>fillSwitch:</string>  
							<string>hide:</string>  
							<string>keyboardDone:</string>  
							<string>less:</string>  
							<string>more:</string>  
						</object>  
						<object class="NSMutableArray" key="dict.values">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<object class="IBActionInfo">  
								<string key="name">adjustPoints:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
							<object class="IBActionInfo">  
								<string key="name">backgroundTouch:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
							<object class="IBActionInfo">  
								<string key="name">fillSwitch:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
							<object class="IBActionInfo">  
								<string key="name">hide:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
							<object class="IBActionInfo">  
								<string key="name">keyboardDone:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
							<object class="IBActionInfo">  
								<string key="name">less:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
							<object class="IBActionInfo">  
								<string key="name">more:</string>  
								<string key="candidateClassName">id</string>  
							</object>  
						</object>  
					</object>  
					<object class="NSMutableDictionary" key="outlets">  
						<bool key="EncodedWithXMLCoder">YES</bool>  
						<object class="NSArray" key="dict.sortedKeys">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<string>displayText</string>  
							<string>textInput</string>  
						</object>  
						<object class="NSMutableArray" key="dict.values">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<string>UILabel</string>  
							<string>UITextField</string>  
						</object>  
					</object>  
					<object class="NSMutableDictionary" key="toOneOutletInfosByName">  
						<bool key="EncodedWithXMLCoder">YES</bool>  
						<object class="NSArray" key="dict.sortedKeys">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<string>displayText</string>  
							<string>textInput</string>  
						</object>  
						<object class="NSMutableArray" key="dict.values">  
							<bool key="EncodedWithXMLCoder">YES</bool>  
							<object class="IBToOneOutletInfo">  
								<string key="name">displayText</string>  
								<string key="candidateClassName">UILabel</string>  
							</object>  
							<object class="IBToOneOutletInfo">  
								<string key="name">textInput</string>  
								<string key="candidateClassName">UITextField</string>  
							</object>  
						</object>  
					</object>  
					<object class="IBClassDescriptionSource" key="sourceIdentifier">  
						<string key="majorKey">IBProjectSource</string>  
						<string key="minorKey">src/gui/MyGuiView.h</string>  
					</object>  
				</object>  
  

(sorry that was long)

but I dont have either of these references in my new .xib file.
Perhaps it is oblivious to what file it should be associated with ?

Ok, got them linking now…

I used ‘File > Read Class Files’ and pointed at my h file
InterfaceBuilder complained there were no classes found
Then I set my File’s Owner class to MyGuiView
and I could link the View to File Owner’s view

still sigabrt…

ok solved.

had to set class name to ‘MyMusicView’

not sure where that’s referenced from (quick spotlight search over ofxiphone files shows no references).

anyway, hope my log helps!

next issue…

if i design a landscape interface
and use:

  
	ofxiPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT);  

then my interface is still rendered in portrait (it overflows the edge of the screen and doesn’t cover all the way to the bottom).

Also my view blocks out my openFrameworks rendering. I tried ‘Clear Context Before Drawing’ is disabled on the View and everything in it, but didn’t appear to help.

Your view is probably blocking your openFrameworks view because it is not transparent. You can make your view transparent in Interface Builder or programmatically.

Note that the views you add are always rendered on top of your openFrameworks view and that touches cannot be received in openFrameworks if the other view is on top of it.

The best way to work might be working with a standard iPhone navigation bar and popovers. I’ve made an example with the imagepicker over here: http://forum.openframeworks.cc/t/camera-gt;openlibrary;-on-ipad-ofxiphoneimagepicker/4570/0

hi elliotwoods

did you find out how to display the gui in landscape orientation ?

thanks,
stephan.

Looks like if you add this override function to MyGuiView.mm then the landscape orientation works properly with the buttons:

  
  
//----------------------------------------------------------------  
// Override to allow orientations other than the default portrait orientation.  
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {  
    // Return YES for supported orientations  
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);  
}  

I also had this problem when creating a new View from scratch (since I couldn’t read Theo’s example using XCode 4.3.

The way I fixed it was, in the Interface Builder, you have to ctrl-click on the File Owner and drag over to the View object, then attach it to “view”, as mentioned here: http://robertcarlsen.net/2009/05/31/using-openframeworks-for-iphone-dev-757

Good old drag-n-drop programming. Great idea, Apple.