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 09-13-2008, 06:42 PM   #1 (permalink)
varchar
Registered Member
 
Join Date: Aug 2008
Posts: 100
varchar is on a distinguished road
Default Loading subview within viewcontroller programmatically

Is anyone familiar with how to initialize/load a sub-view programmatically within an existing view which is part of a viewcontroller.

Here is the entire situation:

MyView.nib - created using interface builder. This nib has a UIView and another UIView [subview] within it. It uses MyViewController.

If I assign the class mysubview via interface builder. It works smoothly, no problemo.

But what I am interested in doing is loading the subview programmatically within a view controller, after some logic is done in the main view. (i.e. after I call a web service and depending on the results then I may want to load the subview). If assigning it directly in interface builder, it loads automatically, which defeats purpose of what i want to do.

I was figuring maybe I can load it via assigning the class similar to below within the viewcontroller:

myview1 = mysubview;

Obviously it is not working...





MySubView.h

Code:

@interface MySubView : UIWebView {	
	
}


@end
MySubView.M

Code:

#import "MySubView.h"

@interface MySubView (Private)
- (void) loadMap;
@end

@implementation MySubView


//------------------------------------------------------------------------------
- (void) didMoveToSuperview {
    // this hook method is used to initialize the view; we don't want 
    // any user input to be delivered to the UIWebView.

    self.userInteractionEnabled = NO;
    self.scalesPageToFit = NO;
    self.autoresizingMask = 
    	UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    
	[self loadMap];
}


MyViewController.h

Code:

@interface MyViewController : UIViewController {

	IBOutlet UIView *mySubView1;
	
}

@end
varchar is offline   Reply With Quote
 

» Advertisements
» Online Users: 525
22 members and 503 guests
baja_yu, bignoggins, checkright, Chickenrig, David-T, dljeffery, dre, dvw, eski, Gaz, givensur, JoeRCruso, LunarMoon, marleneZ, RickSDK, sacha1996, spiderguy84, TheStalker, toolifog, ukneeq, vbovio, wandou
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,548
Threads: 94,073
Posts: 402,706
Top Poster: BrianSlick (7,990)
Welcome to our newest member, mrtdmb
Powered by vBadvanced CMPS v3.1.0

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