Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

A Problem With Removing a Subview

George the MacGeorge the Mac Posts: 14Registered Users
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:UIViewAnimationTransitionCurlDown
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.:confused: Any help is
appreciated.
Post edited by George the Mac on

Replies

  • tawpietawpie Posts: 348Registered Users
    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.

    <a href="htt
  • George the MacGeorge the Mac Posts: 14Registered Users
    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!
    -(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];
    }
Sign In or Register to comment.