0

I've got an application with several modal view controllers. Most of them work fine except for one that is within a UINavigationController (so that I can show a navbar). When this modal view controller is displayed it animates fine but when dismissed it does not animate. I'd really like it to animate. Any thoughts?

Thanks much!

Here is the modal view controller (I've simplified the code, hopefully not too much!):

@protocol SettingsDelegate;

@interface Settings : UIViewController <UITextFieldDelegate> {
       id<SettingsDelegate> delegate;
}
@property (assign) id<SettingsDelegate> delegate;

@end

@protocol SettingsDelegate <NSObject>

@optional
- (void)Settings:(Settings *)controller dismissModalController:(NSString *)foo;

@end

The main routine .h looks like:

#import "Settings.h"

@interface MainPageController : UIViewController <SettingsDelegate> {
}
@end

The main routine .m looks like this:

- (void)Settings:(Settings *)controller dismissModalController:(NSString *)foo {
    [self dismissModalViewControllerAnimated:YES];
}

- (void)doSettings {
       Settings *addController = [[Settings alloc] initWithNibName:@"Settings" bundle:nil];
       addController.delegate = self;
       UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController];
       [self presentModalViewController:navigationController animated:YES];
}

1 Answer 1

3

It all looks fine, my guess is you are releasing something before you are meant to and it is resulting in the view disappearing. Remove your release statements and see if it fixes the problem, then work backwards to see where it went wrong.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. You pointed me in the right direction - while I was checking my release statements I found I was dismissing the modal incorrectly. All works now! Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.