this notification can be removed
authorkoda
Sat, 28 May 2011 16:40:23 +0200
changeset 5219 9e2a17ab178b
parent 5218 bc31676ae108
child 5220 76a2246f18f0
this notification can be removed
project_files/HedgewarsMobile/Classes/MainMenuViewController.m
project_files/HedgewarsMobile/Classes/MasterViewController.h
project_files/HedgewarsMobile/Classes/MasterViewController.m
project_files/HedgewarsMobile/Classes/SplitViewRootController.m
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat May 28 16:59:09 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat May 28 16:40:23 2011 +0200
@@ -93,12 +93,6 @@
 -(void) viewDidLoad {
     [super viewDidLoad];
 
-    // listen to request to remove the modalviewcontroller (needed due to the splitcontroller)
-    [[NSNotificationCenter defaultCenter] addObserver:self
-                                             selector:@selector(dismissModalViewController)
-                                                 name: @"dismissModalView"
-                                               object:nil];
-
     // get the app's version
     NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
 
@@ -210,13 +204,7 @@
     }
 }
 
-// must be kept for compatibility with the settings page
--(void) dismissModalViewController {
-    [self dismissModalViewControllerAnimated:YES];
-}
-
 -(void) viewDidUnload {
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
     self.gameConfigViewController = nil;
     self.settingsViewController = nil;
     self.aboutViewController = nil;
--- a/project_files/HedgewarsMobile/Classes/MasterViewController.h	Sat May 28 16:59:09 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/MasterViewController.h	Sat May 28 16:40:23 2011 +0200
@@ -22,7 +22,7 @@
 #import <UIKit/UIKit.h>
 
 
-@class DetailViewController;
+@class SplitViewRootController;
 @class GeneralSettingsViewController;
 @class TeamSettingsViewController;
 @class WeaponSettingsViewController;
@@ -30,6 +30,7 @@
 @class SupportViewController;
 
 @interface MasterViewController : UITableViewController {
+    SplitViewRootController *rootController;
     MasterViewController *targetController;
     NSArray *controllerNames;
     NSIndexPath *lastIndexPath;
@@ -41,6 +42,7 @@
 }
 
 @property (nonatomic, retain) MasterViewController *targetController;
+@property (nonatomic, retain) SplitViewRootController *rootController;
 @property (nonatomic, retain) NSArray *controllerNames;
 @property (nonatomic, retain) NSIndexPath *lastIndexPath;
 
--- a/project_files/HedgewarsMobile/Classes/MasterViewController.m	Sat May 28 16:59:09 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/MasterViewController.m	Sat May 28 16:40:23 2011 +0200
@@ -28,7 +28,7 @@
 #import "SupportViewController.h"
 
 @implementation MasterViewController
-@synthesize targetController, controllerNames, lastIndexPath;
+@synthesize rootController, targetController, controllerNames, lastIndexPath;
 
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
@@ -192,7 +192,8 @@
 }
 
 -(void) viewDidUnload {
-    self.targetController = nil;
+    //self.rootController = nil;
+    //self.targetController = nil;
     self.controllerNames = nil;
     self.lastIndexPath = nil;
     generalSettingsViewController = nil;
@@ -205,7 +206,8 @@
 }
 
 -(void) dealloc {
-    self.targetController = nil;
+    releaseAndNil(rootController);
+    releaseAndNil(targetController);
     releaseAndNil(controllerNames);
     releaseAndNil(lastIndexPath);
     releaseAndNil(generalSettingsViewController);
@@ -217,8 +219,7 @@
 }
 
 -(IBAction) dismissSplitView {
-    playSound(@"backSound");
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
+    [self.rootController dismissModalViewControllerAnimated:YES];
 }
 
 @end
--- a/project_files/HedgewarsMobile/Classes/SplitViewRootController.m	Sat May 28 16:59:09 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/SplitViewRootController.m	Sat May 28 16:40:23 2011 +0200
@@ -45,6 +45,7 @@
 
     if (self.activeController == nil) {
         MasterViewController *rightController = [[MasterViewController alloc] initWithStyle:UITableViewStyleGrouped];
+        rightController.rootController = self;
         rightController.targetController = nil;
         self.activeController = rightController;
         [rightController release];
@@ -53,6 +54,7 @@
 
     if (IS_IPAD()) {
         MasterViewController *leftController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
+        leftController.rootController = self;
         leftController.targetController = self.activeController;
         UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController];
         [leftController release];
@@ -74,6 +76,11 @@
     [super viewDidLoad];
 }
 
+-(void) dismissModalViewControllerAnimated:(BOOL)animated {
+    playSound(@"backSound");
+    [self.parentViewController dismissModalViewControllerAnimated:YES];
+}
+
 -(void) viewDidUnload {
     self.activeController = nil;
     self.rightNavController = nil;