The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > Omni Frameworks
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
ScalingScrollViewViewController how to init without a XIB? Thread Tools Search this Thread Display Modes
I'm trying to get the sample ScalingScrollView app to work in my App, though I wanted to make it a Tab in my Tab bar and I do not want to use a XIB file.

I've tried with and without adding to the Tab bar and I cannot seem to get the redbox to draw, my viewDidLoad is not getting fired.

My ScalingScrollViewViewController initWithFrame looks like this:
Code:
-(id)initWithFrame:(CGRect)viewRect{
	self = [super init];
	_masterView = [[UIView alloc] initWithFrame:viewRect];
	_scalingScrollView = [[OUIScalingScrollView alloc] initWithFrame:viewRect];
	_scalingView = [[ScalingView alloc] initWithFrame:viewRect];
	[_scalingView setScale:2.0];
	
	[_scalingScrollView  setDelegate:self];
	//[_scalingScrollView   addSubview:_scalingView];
	//[_masterView   addSubview:_scalingScrollView];
	[self setScalingView:_scalingView];
	[self setScrollView:_scalingScrollView];
	[self setView:_masterView];
	
	UITabBarItem *tbi = [self tabBarItem];
	
	[tbi setTitle:@"ScaleScroll"];
	
	UIImage *i = [UIImage imageNamed:@"wateringcan.png"];
	[tbi setImage:i];
	[self setTabBarItem:tbi];
	//[self sizeInitialViewSizeFromCanvasSize];
	[self adjustScaleTo:2.0];
	return self;
}
I see it adjusting the scale and stuff, but its just not displaying the view.
Here is my application didFinishLaunchingWithOptions code:

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
	
	tabBarController = [[UITabBarController alloc] init];
	
	//Create Vierw Controllers
	UIViewController *vc1 = [[sprinklerViewController alloc] init];
	UIViewController *vc2 = [[sprinklerViewController alloc] init];
	UIViewController *vc3 = [[splitViewController alloc] init];
	CGRect viewRect = CGRectMake(0.0, 0.0, 500, 400);
	ScalingScrollViewViewController *vc4 = [[ScalingScrollViewViewController alloc] initWithFrame:viewRect];

	//Make array containing View Controllers
	NSArray *viewControllers = [NSArray arrayWithObjects:vc4, vc2, vc3, vc1, nil];
	
	[vc1 release];
	[vc2 release];
	[vc3 release];
	[vc4 release];
	
	//Attach VC Array to TB
	[tabBarController setViewControllers:viewControllers];
	
	[window addSubview:[tabBarController view]];
	[window makeKeyAndVisible];
	return YES;
}
My other tabs show up just fine. So I'm thinking its the way I'm trying to recreate the ScalingScrollViewViewController.xib file in code.

Any tips would be great.
 
It looks like you have commented out the -addSubview: calls that hook up the view hierarchy -- those would be necessary.

Also, passing viewRect as the frame of all the views is dangerous. If the origin of viewRect is non-zero, the subviews will have their origin offset from the origin of their superview (possibly accounting for things not showing up). You'll want to pass viewRect as the frame of _masterView and then pass {0, 0, viewRect.size.width, viewRect.size.height} as the frame of the subviews.

Other than that, this looks reasonable.

You might try setting a different background color on all the views in question to make sure you can see where they are positioned. If everything is going right, you'd only see the background color for the scalingView.
__________________
CTO, The Omni Group
 
I thought that the calls to :
Code:
	[self setScalingView:_scalingView];
	[self setScrollView:_scalingScrollView];
would have added them to the view.

So with that and the viewRect issue fixed I think I have it figured out.

Now to Subclass the OIUScalingView to create my own view and pass it in to my ViewController. (-;

Thanks again for great framework.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 10:48 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.