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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-22-2010, 04:31 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 1
captaindan is on a distinguished road
Default subview & viewcontroller confusion

Hello everyone,

I've spent all evening trying to get to grips with something that I'm sure must be fairly simple. I'm trying to devise a framework that will allow me, within a View Based Application to have a superview XIB, with a UIView (containerView) inside. I then wish to be able to populate containerView with various XIBs, each with its own viewcontroller. I hope this will allow me to build and expand my app to contain many uniquely designed and controlled views. I really hope that i've made a silly rookie mistake in how i've set this up, as whilst I can get the XIB files to load (at the moment triggered by buttons in the superview), I can't get them to respond to touch events.

This is how the XIB is loaded in the IBAction attached to its button:

Code:
UIView *nv = [[[NSBundle mainBundle] loadNibNamed:@"view2" owner:self options:nil] objectAtIndex:0];
[containerView addSubview:nv];
That XIB file has a UIViewController object, with its Class set to "view2". When the XIB is displayed with the button press, I have used NSLog to confirm that -ViewDidLoad is running.

Inside view2.m I have implemented

Code:
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	NSLog(@"touching in view 2");
}
but the application ignores this, and passes the event up the chain to the superview.

I have also added a UIButton to the XIB, and hooked it into an IBOutlet and IBAction in view2.m. If I change the property of the button in ViewDidLoad, for instance changing its background colour, then it works fine. However, the when the IBAction is called it kills the app.

Am I barking totally up the wrong tree here? Any clues as to what i've messed up? My instinct is that i've misunderstood some element of the UIView/view controller relationship, and I'd be very grateful for any insight as to where my logic falls over.

I will say one other thing that appears odd, in view2.xib, File Owner's 'view' outlet is not set - this feels wrong, but if I set it to the View then nothing appears when I click on the button in the superview.

Any help really appreciated, and thank you for putting up with my dyslexic ramblings.

Many Thanks,

Dan
captaindan is offline   Reply With Quote
Reply

Bookmarks

Tags
uiview, uiviewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 313
20 members and 293 guests
baja_yu, cgokey, Domele, Duncan C, Fstuff, gbenna, givensur, guusleijsten, HowEver, iphonedevshani, jbro, JoeRCruso, mdpauley, n00b, newDev, seokwon lee, SLIC, stanny, Steven.C, WheyLabs
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,112
Posts: 402,875
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:33 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0