Source

Kurts iPad/iPhone iOS4 Changes / 54.diff

Full commit
# HG changeset patch
# User karnlund
# Date 1277172743 25200
# Node ID 74adfb66e4462f545eff76c41a3f1d2500c414ee
# Parent  dbd392c8a972e9f329b98c967ade79122b8fb91e
[mq]: first.patch

diff -r dbd392c8a972 -r 74adfb66e446 InAppSettings/Cells/InAppSettingsTableCell.h
--- a/InAppSettings/Cells/InAppSettingsTableCell.h	Wed Mar 17 00:03:09 2010 -0700
+++ b/InAppSettings/Cells/InAppSettingsTableCell.h	Mon Jun 21 19:12:23 2010 -0700
@@ -14,12 +14,14 @@
     UILabel *titleLabel, *valueLabel;
     UIControl *valueInput;
     BOOL canSelectCell;
+	CGFloat cellWidth;
 }
 
 @property (nonatomic, retain) InAppSettingsSpecifier *setting;
 @property (nonatomic, retain) UILabel *titleLabel, *valueLabel;
 @property (nonatomic, assign) UIControl *valueInput;
 @property (nonatomic, assign) BOOL canSelectCell;
+@property (nonatomic) CGFloat cellWidth;
 
 - (void)setTitle;
 - (void)setDetail;
@@ -30,6 +32,6 @@
 
 - (void)setupCell;
 - (void)setUIValues;
-- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier;
+- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier andWidth:(CGFloat)newWidth;
 
 @end
diff -r dbd392c8a972 -r 74adfb66e446 InAppSettings/Cells/InAppSettingsTableCell.m
--- a/InAppSettings/Cells/InAppSettingsTableCell.m	Wed Mar 17 00:03:09 2010 -0700
+++ b/InAppSettings/Cells/InAppSettingsTableCell.m	Mon Jun 21 19:12:23 2010 -0700
@@ -15,6 +15,7 @@
 @synthesize titleLabel, valueLabel;
 @synthesize valueInput;
 @synthesize canSelectCell;
+@synthesize cellWidth;
 
 #pragma mark Cell lables
 
@@ -99,11 +100,17 @@
 
 #pragma mark -
 
-- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier{
+- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier andWidth:(CGFloat)newWidth{
     //the docs say UITableViewCellStyleValue1 is used for settings, 
     //but it doesn't look 100% the same so we will just draw our own UILabels
     #if InAppSettingsUseNewCells
     self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
+	CGRect newFrame = self.frame;
+	newFrame.size.width = newWidth;
+	self.frame = newFrame;
+	cellWidth = newWidth;
+	DLog(@"%@", CFMakeCollectable(CGRectCreateDictionaryRepresentation(self.frame)));
+		 
     #else
     self = [super initWithFrame:CGRectZero reuseIdentifier:reuseIdentifier];
     #endif
@@ -126,11 +133,13 @@
 }
 
 - (void)setupCell{
+
     //setup title label
     self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
     self.titleLabel.font = InAppSettingsBoldFont;
     self.titleLabel.highlightedTextColor = [UIColor whiteColor];
     self.titleLabel.backgroundColor = [UIColor clearColor];
+
 //    self.titleLabel.backgroundColor = [UIColor greenColor];
     [self.contentView addSubview:self.titleLabel];
     
@@ -140,6 +149,7 @@
     self.valueLabel.textColor = InAppSettingsBlue;
     self.valueLabel.highlightedTextColor = [UIColor whiteColor];
     self.valueLabel.backgroundColor = [UIColor clearColor];
+
 //    self.valueLabel.backgroundColor = [UIColor redColor];
     [self.contentView addSubview:self.valueLabel];
 }
diff -r dbd392c8a972 -r 74adfb66e446 InAppSettings/InAppSettings.m
--- a/InAppSettings/InAppSettings.m	Wed Mar 17 00:03:09 2010 -0700
+++ b/InAppSettings/InAppSettings.m	Mon Jun 21 19:12:23 2010 -0700
@@ -38,6 +38,7 @@
 @synthesize settingsReader;
 @synthesize delegate;
 
+
 #pragma mark modal view
 
 - (void)dismissModalView{
@@ -65,8 +66,17 @@
 
 - (void)viewDidLoad{
     //setup the table
-    self.settingsTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
-    self.settingsTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
+	CGRect tableBounds = self.view.bounds;
+	
+	if (self.parentViewController) {
+		tableBounds = self.parentViewController.view.bounds;
+	}
+	
+	self.contentSizeForViewInPopover = tableBounds.size;
+	
+	DLog(@" parent VC bounds %@", CFMakeCollectable( CGRectCreateDictionaryRepresentation(tableBounds) ));
+	
+    self.settingsTableView = [[UITableView alloc] initWithFrame:tableBounds style:UITableViewStyleGrouped];
     self.settingsTableView.delegate = self;
     self.settingsTableView.dataSource = self;
     [self.view addSubview:self.settingsTableView];
@@ -91,8 +101,8 @@
 - (void)viewWillAppear:(BOOL)animated {
     self.firstResponder = nil;
     
-    self.settingsTableView.contentInset = UIEdgeInsetsZero;
-    self.settingsTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
+//    self.settingsTableView.contentInset = UIEdgeInsetsZero;
+//    self.settingsTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
     
     [self.settingsTableView reloadData];
     [super viewWillAppear:animated];
@@ -143,6 +153,7 @@
 
 - (void)keyboardWillShow:(NSNotification*)notification{
     if(self.firstResponder == nil){
+		DLog(@"");
         // get the keybaord rect
         CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
         
@@ -163,6 +174,7 @@
 
 - (void)keyboardWillHide:(NSNotification*)notification{
     if(self.firstResponder == nil){
+		DLog(@"");
         [UIView beginAnimations:nil context:nil];
         [UIView setAnimationDuration:InAppSettingsKeyboardAnimation];
         [UIView setAnimationBeginsFromCurrentState:YES];
@@ -207,11 +219,13 @@
 
 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
     if(InAppSettingsDisplayPowered && [self.file isEqualToString:InAppSettingsRootFile] && section == (NSInteger)[self.settingsReader.headers count]-1){
-        UIView *powerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, InAppSettingsScreenWidth, InAppSettingsPowerFooterHeight)];
+		CGRect parentBounds = self.parentViewController.view.bounds;
+		CGFloat parentWidth = parentBounds.size.width;
+        UIView *powerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, parentWidth, InAppSettingsPowerFooterHeight)];
         
         //InAppSettings label
         CGSize InAppSettingsSize = [InAppSettingsProjectName sizeWithFont:InAppSettingsFooterFont];
-        CGPoint InAppSettingsPos = CGPointMake((CGFloat)round((InAppSettingsScreenWidth*0.5f)-(InAppSettingsSize.width*0.5f)), 
+        CGPoint InAppSettingsPos = CGPointMake((CGFloat)round((parentWidth*0.5f)-(InAppSettingsSize.width*0.5f)), 
                                                (CGFloat)round((InAppSettingsPowerFooterHeight*0.5f)-(InAppSettingsSize.height*0.5f))-1);
         UILabel *InAppLabel = [[UILabel alloc] initWithFrame:CGRectMake(InAppSettingsPos.x, InAppSettingsPos.y, InAppSettingsSize.width, InAppSettingsSize.height)];
         InAppLabel.text = InAppSettingsProjectName;
@@ -259,7 +273,7 @@
     
     InAppSettingsTableCell *cell = ((InAppSettingsTableCell *)[tableView dequeueReusableCellWithIdentifier:cellType]);
     if (cell == nil){
-        cell = [[[nsclass alloc] initWithReuseIdentifier:cellType] autorelease];
+        cell = [[[nsclass alloc] initWithReuseIdentifier:cellType andWidth:self.view.frame.size.width] autorelease];
         //setup the cells controlls
         [cell setupCell];
     }
@@ -276,10 +290,12 @@
     InAppSettingsSpecifier *setting = [self settingAtIndexPath:indexPath];
     if([setting isType:InAppSettingsPSMultiValueSpecifier]){
         InAppSettingsPSMultiValueSpecifierTable *multiValueSpecifier = [[InAppSettingsPSMultiValueSpecifierTable alloc] initWithSetting:setting];
+		multiValueSpecifier.contentSizeForViewInPopover = self.contentSizeForViewInPopover;
         [self.navigationController pushViewController:multiValueSpecifier animated:YES];
         [multiValueSpecifier release];
     }else if([setting isType:InAppSettingsPSChildPaneSpecifier]){
         InAppSettingsViewController *childPane = [[InAppSettingsViewController alloc] initWithFile:[setting valueForKey:InAppSettingsSpecifierFile]];
+		childPane.contentSizeForViewInPopover = self.contentSizeForViewInPopover;
         childPane.title = [setting localizedTitle];
         [self.navigationController pushViewController:childPane animated:YES];
         [childPane release];
diff -r dbd392c8a972 -r 74adfb66e446 InAppSettings/InAppSettingsConstants.h
--- a/InAppSettings/InAppSettingsConstants.h	Wed Mar 17 00:03:09 2010 -0700
+++ b/InAppSettings/InAppSettingsConstants.h	Mon Jun 21 19:12:23 2010 -0700
@@ -23,7 +23,7 @@
 #define InAppSettingsCellDisclosureIndicatorWidth 10.0f
 #define InAppSettingsTotalCellPadding InAppSettingsCellPadding*2
 #define InAppSettingsTotalTablePadding InAppSettingsTablePadding*2
-#define InAppSettingsScreenWidth 320
+#define InAppSettingsScreenWidth (self.cellWidth)
 #define InAppSettingsScreenHeight 480
 #define InAppSettingsCellTitleMaxWidth InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsTotalCellPadding)
 #define InAppSettingsFooterFont [UIFont systemFontOfSize:14.0f]