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 03-07-2009, 11:28 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 14
George the Mac is on a distinguished road
Default A Problem With Removing a Subview

My problem is that the subview won't leave the view. Here's my code:
Code in the view controller to be removed. This runs.
-(IBAction)qButtonPressed{
RootViewController *myViewController = [[RootViewController alloc]
init];//WithNibName:@"MainWindow" bundle:nil];
[myViewController removegvView];
[myViewController release];

}
RootVIewController.h
@class GameViewController;
....
GameViewController *gvController;

}
@property (nonatomic, retain)GameViewController *gvController;
-(void)removegvView;
...
RootViewController.m
.....
-(void)loadGvController {
GameViewController *viewController = [[GameViewController alloc]
initWithNibName:@"GameView" bundle:nil];
self.gvController = viewController;
[viewController release];

}
-(void)removegvView{
if (gvController == nil) {
[self loadGvController];
}
UIView *gvView = gvController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCu rlDown
forView:self.view cache:YES];
[gvController viewWillDisappear:YES];
[gvView removeFromSuperview];
[gvController viewDidDisappear:YES];
[UIView commitAnimations];
//This code runs, but nothing happens.
}
......
It builds without any errors & warnings. I'm stumped. Any help is
appreciated.
George the Mac is offline   Reply With Quote
Old 03-11-2009, 12:52 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 14
George the Mac is on a distinguished road
Default Help Anyone??

Suggestions?
George the Mac is offline   Reply With Quote
Old 03-11-2009, 11:06 PM   #3 (permalink)
Registered Member
 
tawpie's Avatar
 
Join Date: Jul 2008
Posts: 347
tawpie is an unknown quantity at this point
Default

George... there's a lot of stuff either not included or that you are missing.

First off, you created gvView in the removegvView method which is an odd place to put it, but since it was never added to a view removing it with removeFromSuperview will probably make things crash at some point.

You need to create gvView somewhere else (loadView is common), then add it to the window or content view or some existing view... after that when you want it to go away you remove it from the superView.

Go to the dev center and grab one of the non-IB based examples on how to put views up programatically. It'll get you miles along your way!
__________________
"Hardware will break. Software comes broken" Unknown
Calc-12E <-- ditch your old calculator.
CPR•Choking <-- Review your training, just in case. (Free)
All of Nature NW <-- scrolls in x and y, with pinch zoom AND scrollable text to boot. It can be done ('taint easy tho)
tawpie is offline   Reply With Quote
Old 03-11-2009, 11:22 PM   #4 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 14
George the Mac is on a distinguished road
Default The rest of the code

Here's the rest. the code is a modified version of the utility template code. Also several other views in the app use the type of code and work.
Thanks for replying!
Code:
-(void)gameToggleView{
	[self removePGToggleView];
	if (gvController == nil) {
        [self loadGvController];
    }
		
    UIView *gameView = gvController.view;
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
    
	[gvController viewWillAppear:YES];
	[self.view addSubview:gameView];
	[gvController viewDidAppear:YES];
	
    [UIView commitAnimations];	
	[gvController sGame];
}
George the Mac is offline   Reply With Quote
Reply

Bookmarks

Tags
problem, remove, subview, view

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: 340
3 members and 337 guests
guusleijsten, Kryckter, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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