finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
authorkoda
Sun, 09 Oct 2011 03:04:45 +0200
changeset 6109 f6726ec81e64
parent 6108 7a8da11a6144
child 6110 e7c62d53d2fd
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib
project_files/HedgewarsMobile/Classes/MapConfigViewController-iPhone.xib
project_files/HedgewarsMobile/Classes/MapConfigViewController.h
project_files/HedgewarsMobile/Classes/MapConfigViewController.m
project_files/HedgewarsMobile/Classes/MapPreviewButtonView.h
project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib	Sun Oct 09 01:45:12 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib	Sun Oct 09 03:04:45 2011 +0200
@@ -117,38 +117,6 @@
 						<float key="IBUIValue">0.05000000074505806</float>
 						<float key="IBUIMaxValue">0.05000000074505806</float>
 					</object>
-					<object class="IBUIButton" id="326163764">
-						<reference key="NSNextResponder" ref="191373211"/>
-						<int key="NSvFlags">289</int>
-						<string key="NSFrame">{{736, 26}, {256, 128}}</string>
-						<reference key="NSSuperview" ref="191373211"/>
-						<bool key="IBUIOpaque">NO</bool>
-						<bool key="IBUIClipsSubviews">YES</bool>
-						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
-						<int key="IBUIContentHorizontalAlignment">0</int>
-						<int key="IBUIContentVerticalAlignment">0</int>
-						<object class="NSFont" key="IBUIFont" id="261639815">
-							<string key="NSName">Helvetica-Bold</string>
-							<double key="NSSize">15</double>
-							<int key="NSfFlags">16</int>
-						</object>
-						<double key="IBUIImageEdgeInsets.top">4</double>
-						<double key="IBUIImageEdgeInsets.bottom">4</double>
-						<double key="IBUIImageEdgeInsets.left">4</double>
-						<double key="IBUIImageEdgeInsets.right">4</double>
-						<object class="NSColor" key="IBUIHighlightedTitleColor" id="437070330">
-							<int key="NSColorSpace">3</int>
-							<bytes key="NSWhite">MQA</bytes>
-						</object>
-						<object class="NSColor" key="IBUINormalTitleColor">
-							<int key="NSColorSpace">1</int>
-							<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
-						</object>
-						<object class="NSColor" key="IBUINormalTitleShadowColor" id="65043801">
-							<int key="NSColorSpace">3</int>
-							<bytes key="NSWhite">MC41AA</bytes>
-						</object>
-					</object>
 					<object class="IBUILabel" id="634417433">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
@@ -246,13 +214,23 @@
 						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
 						<int key="IBUIContentHorizontalAlignment">0</int>
 						<int key="IBUIContentVerticalAlignment">0</int>
-						<reference key="IBUIFont" ref="261639815"/>
-						<reference key="IBUIHighlightedTitleColor" ref="437070330"/>
+						<object class="NSFont" key="IBUIFont" id="261639815">
+							<string key="NSName">Helvetica-Bold</string>
+							<double key="NSSize">15</double>
+							<int key="NSfFlags">16</int>
+						</object>
+						<object class="NSColor" key="IBUIHighlightedTitleColor" id="437070330">
+							<int key="NSColorSpace">3</int>
+							<bytes key="NSWhite">MQA</bytes>
+						</object>
 						<object class="NSColor" key="IBUINormalTitleColor">
 							<int key="NSColorSpace">1</int>
 							<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
 						</object>
-						<reference key="IBUINormalTitleShadowColor" ref="65043801"/>
+						<object class="NSColor" key="IBUINormalTitleShadowColor" id="65043801">
+							<int key="NSColorSpace">3</int>
+							<bytes key="NSWhite">MC41AA</bytes>
+						</object>
 						<object class="NSCustomResource" key="IBUINormalImage">
 							<string key="NSClassName">NSImage</string>
 							<string key="NSResourceName">startGameButton.png</string>
@@ -327,14 +305,6 @@
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBCocoaTouchOutletConnection" key="connection">
-						<string key="label">previewButton</string>
-						<reference key="source" ref="372490531"/>
-						<reference key="destination" ref="326163764"/>
-					</object>
-					<int key="connectionID">13</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBCocoaTouchOutletConnection" key="connection">
 						<string key="label">maxLabel</string>
 						<reference key="source" ref="372490531"/>
 						<reference key="destination" ref="634417433"/>
@@ -443,23 +413,6 @@
 					</object>
 					<int key="connectionID">77</int>
 				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBCocoaTouchEventConnection" key="connection">
-						<string key="label">mapButtonPressed</string>
-						<reference key="source" ref="326163764"/>
-						<reference key="destination" ref="372490531"/>
-						<int key="IBEventType">7</int>
-					</object>
-					<int key="connectionID">113</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBCocoaTouchOutletConnection" key="connection">
-						<string key="label">delegate</string>
-						<reference key="source" ref="326163764"/>
-						<reference key="destination" ref="372490531"/>
-					</object>
-					<int key="connectionID">114</int>
-				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -490,7 +443,6 @@
 							<reference ref="394383001"/>
 							<reference ref="743202682"/>
 							<reference ref="634417433"/>
-							<reference ref="326163764"/>
 							<reference ref="938256702"/>
 							<reference ref="420136851"/>
 							<reference ref="88728219"/>
@@ -536,11 +488,6 @@
 						<reference key="parent" ref="191373211"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">9</int>
-						<reference key="object" ref="326163764"/>
-						<reference key="parent" ref="191373211"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">8</int>
 						<reference key="object" ref="938256702"/>
 						<reference key="parent" ref="191373211"/>
@@ -581,8 +528,6 @@
 					<string>75.IBPluginDependency</string>
 					<string>75.IBViewBoundsToFrameTransform</string>
 					<string>8.IBPluginDependency</string>
-					<string>9.CustomClassName</string>
-					<string>9.IBPluginDependency</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
@@ -618,8 +563,6 @@
 						<bytes key="NSTransformStruct">P4AAAL+AAABEbsAAxDzAAA</bytes>
 					</object>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
-					<string>MapPreviewButtonView</string>
-					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="unlocalizedProperties">
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPhone.xib	Sun Oct 09 01:45:12 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPhone.xib	Sun Oct 09 03:04:45 2011 +0200
@@ -12,6 +12,7 @@
 		</object>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="1"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -46,7 +47,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrameSize">{480, 276}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIUserInteractionEnabled">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 						<object class="NSCustomResource" key="IBUIImage">
@@ -59,7 +59,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{9, 14}, {270, 30}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 						<int key="IBSegmentControlStyle">2</int>
@@ -110,7 +109,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{119, 207}, {149, 23}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 						<int key="IBUIContentHorizontalAlignment">0</int>
@@ -123,7 +121,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{16, 58}, {256, 128}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 						<int key="IBUIContentHorizontalAlignment">0</int>
@@ -151,7 +148,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{58, 221}, {48, 35}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
 						<int key="IBUIContentMode">7</int>
@@ -177,7 +173,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{109, 237}, {169, 29}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
 						<int key="IBUIContentMode">7</int>
@@ -203,7 +198,6 @@
 						<int key="NSvFlags">274</int>
 						<string key="NSFrame">{{284, 0}, {196, 276}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<object class="NSColor" key="IBUIBackgroundColor">
 							<int key="NSColorSpace">3</int>
 							<bytes key="NSWhite">MCAwAA</bytes>
@@ -226,7 +220,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{-9, 225}, {92, 27}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
 						<int key="IBUIContentMode">7</int>
@@ -247,7 +240,6 @@
 				</object>
 				<string key="NSFrameSize">{480, 276}</string>
 				<reference key="NSSuperview"/>
-				<reference key="NSWindow"/>
 				<reference key="IBUIBackgroundColor" ref="437070330"/>
 				<object class="IBUISimulatedToolbarMetrics" key="IBUISimulatedBottomBarMetrics"/>
 				<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
@@ -359,15 +351,6 @@
 					<int key="connectionID">32</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBCocoaTouchEventConnection" key="connection">
-						<string key="label">mapButtonPressed</string>
-						<reference key="source" ref="326163764"/>
-						<reference key="destination" ref="372490531"/>
-						<int key="IBEventType">7</int>
-					</object>
-					<int key="connectionID">33</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBCocoaTouchOutletConnection" key="connection">
 						<string key="label">delegate</string>
 						<reference key="source" ref="326163764"/>
@@ -375,6 +358,15 @@
 					</object>
 					<int key="connectionID">34</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">mapButtonPressed:</string>
+						<reference key="source" ref="326163764"/>
+						<reference key="destination" ref="372490531"/>
+						<int key="IBEventType">7</int>
+					</object>
+					<int key="connectionID">37</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -534,7 +526,7 @@
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">36</int>
+			<int key="maxID">37</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -547,7 +539,7 @@
 						<object class="NSArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>buttonPressed:</string>
-							<string>mapButtonPressed</string>
+							<string>mapButtonPressed:</string>
 							<string>segmentedControlChanged:</string>
 							<string>sliderChanged:</string>
 							<string>sliderEndedChanging:</string>
@@ -566,7 +558,7 @@
 						<object class="NSArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>buttonPressed:</string>
-							<string>mapButtonPressed</string>
+							<string>mapButtonPressed:</string>
 							<string>segmentedControlChanged:</string>
 							<string>sliderChanged:</string>
 							<string>sliderEndedChanging:</string>
@@ -578,7 +570,7 @@
 								<string key="candidateClassName">id</string>
 							</object>
 							<object class="IBActionInfo">
-								<string key="name">mapButtonPressed</string>
+								<string key="name">mapButtonPressed:</string>
 								<string key="candidateClassName">id</string>
 							</object>
 							<object class="IBActionInfo">
@@ -681,11 +673,15 @@
 				</object>
 				<object class="IBPartialClassDescription">
 					<string key="className">UILabel</string>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+					<object class="IBClassDescriptionSource" key="sourceIdentifier" id="812051196">
 						<string key="majorKey">IBProjectSource</string>
 						<string key="minorKey">Classes/HWUtils.h</string>
 					</object>
 				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UITableView</string>
+					<reference key="sourceIdentifier" ref="812051196"/>
+				</object>
 			</object>
 			<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
 				<bool key="EncodedWithXMLCoder">YES</bool>
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.h	Sun Oct 09 01:45:12 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.h	Sun Oct 09 03:04:45 2011 +0200
@@ -84,7 +84,7 @@
 
 -(IBAction) buttonPressed:(id) sender;
 
--(IBAction) mapButtonPressed;
+-(IBAction) mapButtonPressed:(id) sender;
 -(IBAction) sliderChanged:(id) sender;
 -(IBAction) sliderEndedChanging:(id) sender;
 -(IBAction) segmentedControlChanged:(id) sender;
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Sun Oct 09 01:45:12 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Sun Oct 09 03:04:45 2011 +0200
@@ -38,7 +38,7 @@
     return rotationManager(interfaceOrientation);
 }
 
--(IBAction) mapButtonPressed {
+-(IBAction) mapButtonPressed:(id) sender {
     [AudioManagerController playClickSound];
     [self updatePreview];
 }
@@ -57,19 +57,16 @@
     [seedCmd release];
 
     NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
-    NSIndexPath *theIndex;
     if (isRandomness()) {
         // prevent other events and add an activity while the preview is beign generated
         [self turnOffWidgets];
         [self.previewButton updatePreviewWithSeed:seed];
-        theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
-    } else {
-        theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
         // the preview for static maps is loaded in didSelectRowAtIndexPath
     }
     [seed release];
 
     // perform as if user clicked on an entry
+    NSIndexPath *theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
     [self tableView:self.tableView didSelectRowAtIndexPath:theIndex];
     if (IS_NOT_POWERFUL([HWUtils modelType]) == NO)
         [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
@@ -413,6 +410,18 @@
     return dataSourceArray;
 }
 
+-(MapPreviewButtonView *)previewButton {
+    if (previewButton == nil) {
+        MapPreviewButtonView *preview = [[MapPreviewButtonView alloc] initWithFrame:CGRectMake(736, 26, 256, 128)];
+        preview.delegate = self;
+        [preview addTarget:self action:@selector(mapButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
+        [self.view addSubview:preview];
+        self.previewButton = preview;
+        [preview release];
+    }
+    return previewButton;
+}
+
 -(void) viewDidLoad {
     [super viewDidLoad];
 
@@ -488,6 +497,7 @@
 
 -(void) didReceiveMemoryWarning {
     self.dataSourceArray = nil;
+    self.previewButton = nil;
     [super didReceiveMemoryWarning];
 
     if (self.view.superview == nil) {
--- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.h	Sun Oct 09 01:45:12 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.h	Sun Oct 09 03:04:45 2011 +0200
@@ -38,9 +38,8 @@
 
 @property (nonatomic,assign) id<MapPreviewViewDelegate> delegate;
 
--(void) setBackgroundImageRounded:(UIImage *)image forState:(UIControlState)state;
--(void) setImageRounded:(UIImage *)image forState:(UIControlState)state;
--(void) setImageRoundedForNormalState:(UIImage *)image;
+-(void) setImageRounded:(UIImage *)image forState:(UIControlState) controlState;
+-(void) setImageRounded:(UIImage *)image;
 -(void) updatePreviewWithSeed:(NSString *)seed;
 -(void) updatePreviewWithFile:(NSString *)filePath;
 -(void) turnOnWidgets;
--- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m	Sun Oct 09 01:45:12 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m	Sun Oct 09 03:04:45 2011 +0200
@@ -24,6 +24,8 @@
 #import "UIImageExtra.h"
 #import "ServerSetup.h"
 #import <pthread.h>
+#import <QuartzCore/QuartzCore.h>
+
 
 #define INDICATOR_TAG 7654
 
@@ -33,15 +35,8 @@
 -(id) initWithFrame:(CGRect)frame {
     if ((self = [super initWithFrame:frame])) {
         delegate = nil;
-        [self setBackgroundImageRounded:[UIImage whiteImage:frame.size] forState:UIControlStateNormal];
-    }
-    return self;
-}
-
--(id) initWithCoder:(NSCoder *)aDecoder {
-    if ((self = [super initWithCoder:aDecoder])) {
-        delegate = nil;
-        [self setBackgroundImageRounded:[UIImage whiteImage:self.frame.size] forState:UIControlStateNormal];
+        self.backgroundColor = [UIColor whiteColor];
+        self.layer.cornerRadius = 12;
     }
     return self;
 }
@@ -53,16 +48,11 @@
 
 #pragma mark -
 #pragma mark image wrappers
--(void) setBackgroundImageRounded:(UIImage *)image forState:(UIControlState)state {
-    // TODO:http://stackoverflow.com/questions/4272476/setbackgroundimage-behaviour-changed-on-ipad-4-2
-    [self setBackgroundImage:[image makeRoundCornersOfSize:CGSizeMake(12, 12)] forState:state];
+-(void) setImageRounded:(UIImage *)image forState:(UIControlState)controlState {
+    [self setImage:[image makeRoundCornersOfSize:CGSizeMake(12, 12)] forState:controlState];
 }
 
--(void) setImageRounded:(UIImage *)image forState:(UIControlState)state {
-    [self setImage:[image makeRoundCornersOfSize:CGSizeMake(12, 12)] forState:state];
-}
-
--(void) setImageRoundedForNormalState:(UIImage *)image {
+-(void) setImageRounded:(UIImage *)image {
     [self setImageRounded:image forState:UIControlStateNormal];
 }
 
@@ -163,7 +153,7 @@
     previewCGImage = nil;
 
     // all these are performed on the main thread to prevent a leak
-    [self performSelectorOnMainThread:@selector(setImageRoundedForNormalState:)
+    [self performSelectorOnMainThread:@selector(setImageRounded:)
                            withObject:previewImage
                         waitUntilDone:NO];
     [previewImage release];