fixed a little event propagation problem, added rotation support to the scheme setting page
authorkoda
Sun, 12 Feb 2012 11:05:26 +0100
changeset 6672 4f728ccdd06b
parent 6671 5532d5f6285c
child 6673 1ee72dcea263
fixed a little event propagation problem, added rotation support to the scheme setting page
project_files/HedgewarsMobile/Classes/SettingsBaseViewController.m
project_files/HedgewarsMobile/Classes/SettingsContainerViewController.m
project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m
--- a/project_files/HedgewarsMobile/Classes/SettingsBaseViewController.m	Sun Feb 12 10:08:58 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/SettingsBaseViewController.m	Sun Feb 12 11:05:26 2012 +0100
@@ -139,6 +139,16 @@
     [[[HedgewarsAppDelegate sharedAppDelegate] mainViewController] dismissModalViewControllerAnimated:YES];
 }
 
+-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+    if (IS_IPAD() == NO)
+        return;
+
+    if (self.targetController != nil) {
+        CGRect screenRect = [[UIScreen mainScreen] safeBounds];
+        self.view.frame = CGRectMake(0, 0, 320, screenRect.size.height);
+    }
+}
+
 #pragma mark -
 #pragma mark Table view data source
 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
--- a/project_files/HedgewarsMobile/Classes/SettingsContainerViewController.m	Sun Feb 12 10:08:58 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/SettingsContainerViewController.m	Sun Feb 12 11:05:26 2012 +0100
@@ -118,21 +118,28 @@
 -(void) viewDidAppear:(BOOL)animated {
     [self.splitViewRootController.detailViewController viewDidAppear:animated];
     [self.baseController viewDidAppear:animated];
-    [super viewDidLoad];
+    [super viewDidAppear:animated];
 }
 
 -(void) viewDidDisappear:(BOOL)animated {
     [self.splitViewRootController.detailViewController viewDidDisappear:animated];
     [self.baseController viewDidDisappear:animated];
-    [super viewDidUnload];
+    [super viewDidDisappear:animated];
+}
+
+-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+    [self.splitViewRootController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
+    [self.baseController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
 }
 
 -(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
-    if (IS_IPAD() == NO)
-        return;
+    [self.splitViewRootController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
+    [self.baseController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
+}
 
-    CGRect screenRect = [[UIScreen mainScreen] safeBounds];
-    self.splitViewRootController.masterViewController.view.frame = CGRectMake(0, 0, 320, screenRect.size.height);
+-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
+    [self.splitViewRootController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
+    [self.baseController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
 }
 
 @end
--- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m	Sun Feb 12 10:08:58 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m	Sun Feb 12 11:05:26 2012 +0100
@@ -87,6 +87,13 @@
     [schemeFile release];
 }
 
+// force a redraw of the game mod section to reposition the slider
+-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+    if (IS_IPAD() == NO)
+        return;
+    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationFade];
+}
+
 #pragma mark -
 #pragma mark editableCellView delegate
 // set the new value
@@ -166,11 +173,7 @@
                 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
                                                reuseIdentifier:CellIdentifier1] autorelease];
 
-                int offset = 0;
-                if (IS_IPAD())
-                    offset = 50;
-
-                UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)];
+                UISlider *slider = [[UISlider alloc] init];
                 [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
                 [cell.contentView addSubview:slider];
                 [slider release];
@@ -204,6 +207,20 @@
             cellSlider.maximumValue = [[detail objectForKey:@"max"] floatValue];
             cellSlider.minimumValue = [[detail objectForKey:@"min"] floatValue];
             cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue];
+            // redraw the slider here
+            NSInteger hOffset = 260;
+            NSInteger vOffset = 12;
+            NSInteger sliderLength = 150;
+            if (IS_IPAD()) {
+                hOffset = 310;
+                sliderLength = 230;
+                if (IS_ON_PORTRAIT()) {
+                    hOffset = 50;
+                    vOffset = 40;
+                    sliderLength = 285;
+                }
+            }
+            cellSlider.frame = CGRectMake(hOffset, vOffset, sliderLength, 23);
 
             NSString *prestring = nil;
             checkValueString(prestring,cellLabel.text,cellSlider);
@@ -321,11 +338,13 @@
     return sectionTitle;
 }
 
--(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
-    if ([indexPath section] == 2)
+-(CGFloat) tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    if ([indexPath section] == 0)
+        return aTableView.rowHeight;
+    else if ([indexPath section] == 1)
+        return IS_ON_PORTRAIT() ? 72 : aTableView.rowHeight;
+    else
         return 56;
-    else
-        return self.tableView.rowHeight;
 }
 
 #pragma mark -