/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSChildPaneSpecifierCell.h |
---|
0,0 → 1,14 |
// |
// PSChildPaneSpecifierCell.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsTableCell.h" |
@interface InAppSettingsPSChildPaneSpecifierCell : InAppSettingsTableCell {} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSChildPaneSpecifierCell.m |
---|
0,0 → 1,27 |
// |
// PSToggleSwitchSpecifier.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsPSChildPaneSpecifierCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsPSChildPaneSpecifierCell |
- (void)setUIValues{ |
[super setUIValues]; |
[self setTitle]; |
} |
- (void)setupCell{ |
[super setupCell]; |
[self setDisclosure:YES]; |
self.canSelectCell = YES; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSMultiValueSpecifierCell.h |
---|
0,0 → 1,16 |
// |
// PSToggleSwitchSpecifier.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsTableCell.h" |
@interface InAppSettingsPSMultiValueSpecifierCell : InAppSettingsTableCell {} |
- (NSString *)getValueTitle; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSMultiValueSpecifierCell.m |
---|
0,0 → 1,41 |
// |
// PSToggleSwitchSpecifier.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsPSMultiValueSpecifierCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsPSMultiValueSpecifierCell |
- (NSString *)getValueTitle{ |
NSArray *titles = [self.setting valueForKey:InAppSettingsSpecifierTitles]; |
NSArray *values = [self.setting valueForKey:InAppSettingsSpecifierValues]; |
id obj = [self.setting getValue]; |
NSLog(@"%@",obj); |
NSInteger valueIndex = [values indexOfObject:[self.setting getValue]]; |
if((valueIndex >= 0) && (valueIndex < (NSInteger)[titles count])){ |
return InAppSettingsLocalize([titles objectAtIndex:valueIndex], self.setting.stringsTable); |
} |
return nil; |
} |
- (void)setUIValues{ |
[super setUIValues]; |
[self setTitle]; |
[self setDetail:[self getValueTitle]]; |
} |
- (void)setupCell{ |
[super setupCell]; |
[self setDisclosure:YES]; |
self.canSelectCell = YES; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSSliderSpecifierCell.h |
---|
0,0 → 1,20 |
// |
// PSToggleSwitchSpecifier.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsTableCell.h" |
@interface InAppSettingsPSSliderSpecifierCell : InAppSettingsTableCell { |
UISlider *valueSlider; |
} |
@property (nonatomic, retain) UISlider *valueSlider; |
- (void)slideAction; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSSliderSpecifierCell.m |
---|
0,0 → 1,55 |
// |
// PSToggleSwitchSpecifier.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsPSSliderSpecifierCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsPSSliderSpecifierCell |
@synthesize valueSlider; |
- (void)slideAction{ |
[self.setting setValue:[NSNumber numberWithFloat:[self.valueSlider value]]]; |
} |
- (void)setUIValues{ |
[super setUIValues]; |
//get the abolute path to the images |
NSString *minImagePath = [InAppSettingsBundlePath stringByAppendingPathComponent:[self.setting valueForKey:@"MinimumValueImage"]]; |
NSString *maxImagePath = [InAppSettingsBundlePath stringByAppendingPathComponent:[self.setting valueForKey:@"MaximumValueImage"]]; |
//setup the slider |
self.valueSlider.minimumValue = [[self.setting valueForKey:InAppSettingsSpecifierMinimumValue] floatValue]; |
self.valueSlider.maximumValue = [[self.setting valueForKey:InAppSettingsSpecifierMaximumValue] floatValue]; |
self.valueSlider.minimumValueImage = [UIImage imageWithContentsOfFile:minImagePath]; |
self.valueSlider.maximumValueImage = [UIImage imageWithContentsOfFile:maxImagePath]; |
CGRect valueSliderFrame = self.valueSlider.frame; |
valueSliderFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSliderFrame.size.height*0.5f)); |
valueSliderFrame.origin.x = InAppSettingsCellPadding; |
valueSliderFrame.size.width = InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsTotalCellPadding); |
self.valueSlider.frame = valueSliderFrame; |
self.valueSlider.value = [[self.setting getValue] floatValue]; |
} |
- (void)setupCell{ |
[super setupCell]; |
//create the slider |
self.valueSlider = [[UISlider alloc] initWithFrame:CGRectZero]; |
[self.valueSlider addTarget:self action:@selector(slideAction) forControlEvents:UIControlEventTouchUpInside]; |
[self.contentView addSubview:self.valueSlider]; |
} |
- (void)dealloc{ |
[valueSlider release]; |
[super dealloc]; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTextFieldSpecifierCell.h |
---|
0,0 → 1,24 |
// |
// PSToggleSwitchSpecifier.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsTableCell.h" |
@interface InAppSettingsPSTextFieldSpecifierCell : InAppSettingsTableCell { |
UITextField *textField; |
} |
@property (nonatomic, retain) UITextField *textField; |
- (BOOL)isSecure; |
- (UIKeyboardType)getKeyboardType; |
- (UITextAutocapitalizationType)getAutocapitalizationType; |
- (UITextAutocorrectionType)getAutocorrectionType; |
- (void)textChangeAction; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTextFieldSpecifierCell.m |
---|
0,0 → 1,137 |
// |
// PSToggleSwitchSpecifier.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsPSTextFieldSpecifierCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsPSTextFieldSpecifierCell |
@synthesize textField; |
#pragma mark helper methods |
- (BOOL)isSecure{ |
NSNumber *isSecure = [self.setting valueForKey:@"IsSecure"]; |
if(!isSecure){ |
return NO; |
} |
return [isSecure boolValue]; |
} |
- (UIKeyboardType)getKeyboardType{ |
NSString *keyboardType = [self.setting valueForKey:@"KeyboardType"]; |
if([keyboardType isEqualToString:@"NumbersAndPunctuation"]){ |
return UIKeyboardTypeNumbersAndPunctuation; |
} |
else if([keyboardType isEqualToString:@"NumberPad"]){ |
return UIKeyboardTypeNumberPad; |
} |
else if([keyboardType isEqualToString:@"URL"]){ |
return UIKeyboardTypeURL; |
} |
else if([keyboardType isEqualToString:@"EmailAddress"]){ |
return UIKeyboardTypeEmailAddress; |
} |
return UIKeyboardTypeAlphabet; |
} |
- (UITextAutocapitalizationType)getAutocapitalizationType{ |
//this works, but the real settings don't seem to respect these values eventhough they are in the docs |
NSString *autoCapitalizationType = [self.setting valueForKey:@"AutoCapitalizationType"]; |
if([autoCapitalizationType isEqualToString:@"Words"]){ |
return UITextAutocapitalizationTypeWords; |
} |
else if([autoCapitalizationType isEqualToString:@"Sentences"]){ |
return UITextAutocapitalizationTypeSentences; |
} |
else if([autoCapitalizationType isEqualToString:@"AllCharacters"]){ |
return UITextAutocapitalizationTypeAllCharacters; |
} |
return UITextAutocapitalizationTypeNone; |
} |
- (UITextAutocorrectionType)getAutocorrectionType{ |
NSString *autocorrectionType = [self.setting valueForKey:@"AutocorrectionType"]; |
if([autocorrectionType isEqualToString:@"Yes"]){ |
return UITextAutocorrectionTypeYes; |
} |
else if([autocorrectionType isEqualToString:@"No"]){ |
return UITextAutocorrectionTypeNo; |
} |
return UITextAutocorrectionTypeDefault; |
} |
- (void)textChangeAction{ |
NSNumber* isNumtype = [self.setting valueForKey:InAppSettingsSpecifierInAppNumtype]; |
if ( [isNumtype boolValue] ){ |
NSNumber* n = [NSNumber numberWithInt:[self.textField.text intValue]]; |
[self.setting setValue:n]; |
} |
else |
[self.setting setValue:self.textField.text]; |
} |
#pragma mark cell controlls |
- (void)setValueDelegate:(id)delegate{ |
self.textField.delegate = delegate; |
[super setValueDelegate:delegate]; |
} |
- (void)setUIValues{ |
[super setUIValues]; |
[self setTitle]; |
CGRect textFieldFrame = self.textField.frame; |
CGSize titleSize = [titleLabel.text sizeWithFont:titleLabel.font]; |
textFieldFrame.origin.x = (CGFloat)round(titleSize.width+InAppSettingsTotalTablePadding); |
if(textFieldFrame.origin.x < InAppSettingsCellTextFieldMinX){ |
textFieldFrame.origin.x = InAppSettingsCellTextFieldMinX; |
} |
textFieldFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(titleSize.height*0.5f))-InAppSettingsOffsetY; |
textFieldFrame.size.width = (CGFloat)round((InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-textFieldFrame.origin.x); |
textFieldFrame.size.height = titleSize.height; |
self.textField.frame = textFieldFrame; |
self.textField.text = [[self.setting getValue] description]; |
//keyboard traits |
self.textField.secureTextEntry = [self isSecure]; |
self.textField.keyboardType = [self getKeyboardType]; |
self.textField.autocapitalizationType = [self getAutocapitalizationType]; |
self.textField.autocorrectionType = [self getAutocorrectionType]; |
//these are set here so they are set per cell |
//self.textField.delegate = self; |
self.valueInput = self.textField; |
} |
- (void)setupCell{ |
[super setupCell]; |
//create text field |
self.textField =[[UITextField alloc] initWithFrame:CGRectZero]; |
self.textField.textColor = InAppSettingsBlue; |
self.textField.adjustsFontSizeToFitWidth = YES; |
//THIS IS NOT THE BEHAVIOR OF THE SETTINGS APP |
//but we need a way to dismiss the keyboard |
self.textField.returnKeyType = UIReturnKeyDone; |
[self.textField addTarget:self action:@selector(textChangeAction) forControlEvents:UIControlEventEditingChanged]; |
[self.contentView addSubview:self.textField]; |
} |
- (void)dealloc{ |
[textField release]; |
[super dealloc]; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTitleValueSpecifierCell.h |
---|
0,0 → 1,16 |
// |
// PSTitleValueSpecifierCell.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsTableCell.h" |
@interface InAppSettingsPSTitleValueSpecifierCell : InAppSettingsTableCell {} |
- (NSString *)getValueTitle; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTitleValueSpecifierCell.m |
---|
0,0 → 1,45 |
// |
// PSTitleValueSpecifierCell.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsPSTitleValueSpecifierCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsPSTitleValueSpecifierCell |
- (NSString *)getValueTitle{ |
NSArray *titles = [self.setting valueForKey:InAppSettingsSpecifierTitles]; |
NSArray *values = [self.setting valueForKey:InAppSettingsSpecifierValues]; |
if(titles || values){ |
if(([titles count] == 0) || ([values count] == 0) || ([titles count] != [values count])){ |
return nil; |
} |
NSInteger valueIndex = [values indexOfObject:[self.setting getValue]]; |
if((valueIndex >= 0) && (valueIndex < (NSInteger)[titles count])){ |
return [titles objectAtIndex:valueIndex]; |
} |
return nil; |
} |
return [self.setting getValue]; |
} |
- (void)setUIValues{ |
[super setUIValues]; |
[self setTitle]; |
if([self.setting valueForKey:InAppSettingsSpecifierInAppURL]){ |
[self setDisclosure:YES]; |
self.canSelectCell = YES; |
} |
[self setDetail:[self getValueTitle]]; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSToggleSwitchSpecifierCell.h |
---|
0,0 → 1,22 |
// |
// PSToggleSwitchSpecifier.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsTableCell.h" |
@interface InAppSettingsPSToggleSwitchSpecifierCell : InAppSettingsTableCell { |
UISwitch *valueSwitch; |
} |
@property (nonatomic, retain) UISwitch *valueSwitch; |
- (BOOL)getBool; |
- (void)setBool:(BOOL)newValue; |
- (void)switchAction; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSToggleSwitchSpecifierCell.m |
---|
0,0 → 1,84 |
// |
// PSToggleSwitchSpecifier.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsPSToggleSwitchSpecifierCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsPSToggleSwitchSpecifierCell |
@synthesize valueSwitch; |
// The value associated with the preference when the toggle switch |
// is in the ON position. The value type for this key can be any |
// scalar type, including Boolean, String, Number, Date, or Data. |
// If this key is not present, the default value type is a Boolean. |
- (BOOL)getBool{ |
id value = [self.setting getValue]; |
id trueValue = [self.setting valueForKey:@"TrueValue"]; |
id falseValue = [self.setting valueForKey:@"FalseValue"]; |
if([value isEqual:trueValue]){ |
return YES; |
} |
if([value isEqual:falseValue]){ |
return NO; |
} |
//if there is no true or false values the value has to be a bool |
return [value boolValue]; |
} |
- (void)setBool:(BOOL)newValue{ |
id value = [NSNumber numberWithBool:newValue]; |
if(newValue){ |
id trueValue = [self.setting valueForKey:@"TrueValue"]; |
if(trueValue){ |
value = trueValue; |
} |
} |
else{ |
id falseValue = [self.setting valueForKey:@"FalseValue"]; |
if(falseValue){ |
value = falseValue; |
} |
} |
[self.setting setValue:value]; |
} |
- (void)switchAction{ |
[self setBool:[self.valueSwitch isOn]]; |
} |
- (void)setUIValues{ |
[super setUIValues]; |
[self setTitle]; |
self.valueSwitch.on = [self getBool]; |
} |
- (void)setupCell{ |
[super setupCell]; |
//create the switch |
self.valueSwitch = [[UISwitch alloc] initWithFrame:CGRectZero]; |
CGRect valueSwitchFrame = self.valueSwitch.frame; |
valueSwitchFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSwitchFrame.size.height*0.5f))-InAppSettingsOffsetY; |
valueSwitchFrame.origin.x = (CGFloat)round((InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-valueSwitchFrame.size.width); |
self.valueSwitch.frame = valueSwitchFrame; |
[self.valueSwitch addTarget:self action:@selector(switchAction) forControlEvents:UIControlEventValueChanged]; |
[self.contentView addSubview:self.valueSwitch]; |
} |
- (void)dealloc{ |
[valueSwitch release]; |
[super dealloc]; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPotiValueSpecifierCell.h |
---|
0,0 → 1,16 |
// |
// InAppSettingsPotiValueSpecifierCell.h |
// InAppSettingsTestApp |
// |
// Created by Frank Blumenberg on 04.05.10. |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
// |
#import <Foundation/Foundation.h> |
#import "InAppSettings.h" |
@interface InAppSettingsPotiValueSpecifierCell : InAppSettingsTableCell {} |
- (NSString *)getValueTitle; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPotiValueSpecifierCell.m |
---|
0,0 → 1,40 |
// |
// InAppSettingsPotiValueSpecifierCell.m |
// InAppSettingsTestApp |
// |
// Created by Frank Blumenberg on 04.05.10. |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
// |
#import "InAppSettingsPotiValueSpecifierCell.h" |
@implementation InAppSettingsPotiValueSpecifierCell |
- (NSString *)getValueTitle{ |
NSNumber* value = [self.setting getValue]; |
int intValue=[value intValue]; |
if( intValue <= 245 ) |
return [NSString stringWithFormat:@"%@",value]; |
return [NSString stringWithFormat:NSLocalizedString(@"Poti%d",@"Potiname"),256-intValue]; |
} |
- (void)setUIValues{ |
[super setUIValues]; |
[self setTitle]; |
[self setDetail:[self getValueTitle]]; |
} |
- (void)setupCell{ |
[super setupCell]; |
[self setDisclosure:YES]; |
self.canSelectCell = YES; |
} |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsTableCell.h |
---|
0,0 → 1,35 |
// |
// InAppSettingsTableCell.h |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import <UIKit/UIKit.h> |
#import "InAppSettingsSpecifier.h" |
@interface InAppSettingsTableCell : UITableViewCell { |
InAppSettingsSpecifier *setting; |
UILabel *titleLabel, *valueLabel; |
UIControl *valueInput; |
BOOL canSelectCell; |
} |
@property (nonatomic, retain) InAppSettingsSpecifier *setting; |
@property (nonatomic, retain) UILabel *titleLabel, *valueLabel; |
@property (nonatomic, assign) UIControl *valueInput; |
@property (nonatomic, assign) BOOL canSelectCell; |
- (void)setTitle; |
- (void)setDetail; |
- (void)setDetail:(NSString *)detail; |
- (void)setDisclosure:(BOOL)disclosure; |
- (void)setValueDelegate:(id)delegate; |
- (void)setupCell; |
- (void)setUIValues; |
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier; |
@end |
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsTableCell.m |
---|
0,0 → 1,155 |
// |
// InAppSettingsTableCell.m |
// InAppSettingsTestApp |
// |
// Created by David Keegan on 11/21/09. |
// Copyright 2009 InScopeApps{+}. All rights reserved. |
// |
#import "InAppSettingsTableCell.h" |
#import "InAppSettingsConstants.h" |
@implementation InAppSettingsTableCell |
@synthesize setting; |
@synthesize titleLabel, valueLabel; |
@synthesize valueInput; |
@synthesize canSelectCell; |
#pragma mark Cell lables |
- (void)setTitle{ |
self.titleLabel.text = [self.setting localizedTitle]; |
CGSize titleSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font]; |
CGFloat maxTitleWidth = InAppSettingsCellTitleMaxWidth; |
if([self.setting isType:InAppSettingsPSToggleSwitchSpecifier]){ |
maxTitleWidth = InAppSettingsCellTitleMaxWidth-(InAppSettingsCellToggleSwitchWidth+InAppSettingsCellPadding); |
}else if(self.accessoryType == UITableViewCellAccessoryDisclosureIndicator){ |
maxTitleWidth = InAppSettingsCellTitleMaxWidth-(InAppSettingsCellDisclosureIndicatorWidth+InAppSettingsCellPadding); |
} |
if(titleSize.width > maxTitleWidth){ |
titleSize.width = maxTitleWidth; |
} |
CGRect titleFrame = self.titleLabel.frame; |
titleFrame.size = titleSize; |
titleFrame.origin.x = InAppSettingsCellPadding; |
titleFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(titleSize.height*0.5f))-InAppSettingsOffsetY; |
self.titleLabel.frame = titleFrame; |
} |
- (void)setDetail{ |
[self setDetail:[self.setting getValue]]; |
} |
- (void)setDetail:(NSString *)detail{ |
//the detail is not localized |
self.valueLabel.text = detail; |
CGSize valueSize = [self.valueLabel.text sizeWithFont:self.valueLabel.font]; |
CGRect valueFrame = self.valueLabel.frame; |
CGFloat titleRightSide = self.titleLabel.frame.size.width+InAppSettingsTablePadding; |
if([self.setting isType:InAppSettingsPSMultiValueSpecifier] && [[self.setting localizedTitle] length] == 0){ |
valueFrame.origin.x = InAppSettingsCellPadding; |
}else{ |
valueFrame.origin.x = (InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-valueSize.width; |
if(self.accessoryType == UITableViewCellAccessoryDisclosureIndicator){ |
valueFrame.origin.x -= InAppSettingsCellDisclosureIndicatorWidth+InAppSettingsCellPadding; |
} |
if(titleRightSide >= valueFrame.origin.x){ |
valueFrame.origin.x = titleRightSide; |
} |
} |
valueFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSize.height*0.5f))-InAppSettingsOffsetY; |
valueFrame.size.width = InAppSettingsScreenWidth-(valueFrame.origin.x+InAppSettingsTotalTablePadding+InAppSettingsCellPadding); |
if(self.accessoryType == UITableViewCellAccessoryDisclosureIndicator){ |
valueFrame.size.width -= InAppSettingsCellDisclosureIndicatorWidth+InAppSettingsCellPadding; |
} |
//if the width is less then 0 just hide the label |
if(valueFrame.size.width <= 0){ |
self.valueLabel.hidden = YES; |
}else{ |
self.valueLabel.hidden = NO; |
} |
valueFrame.size.height = valueSize.height; |
self.valueLabel.frame = valueFrame; |
} |
- (void)setDisclosure:(BOOL)disclosure{ |
if(disclosure){ |
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
} |
else{ |
self.accessoryType = UITableViewCellAccessoryNone; |
} |
} |
- (void)setCanSelectCell:(BOOL)value{ |
if(value){ |
self.selectionStyle = UITableViewCellSelectionStyleBlue; |
}else{ |
self.selectionStyle = UITableViewCellSelectionStyleNone; |
} |
canSelectCell = value; |
} |
#pragma mark - |
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier{ |
//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]; |
#else |
self = [super initWithFrame:CGRectZero reuseIdentifier:reuseIdentifier]; |
#endif |
if(self != nil){ |
self.canSelectCell = NO; |
} |
return self; |
} |
#pragma mark implement in cell |
- (void)setUIValues{ |
//implement this per cell type |
} |
- (void)setValueDelegate:(id)delegate{ |
//implement in cell |
} |
- (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]; |
//setup value label |
self.valueLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
self.valueLabel.font = InAppSettingsNormalFont; |
self.valueLabel.textColor = InAppSettingsBlue; |
self.valueLabel.highlightedTextColor = [UIColor whiteColor]; |
self.valueLabel.backgroundColor = [UIColor clearColor]; |
// self.valueLabel.backgroundColor = [UIColor redColor]; |
[self.contentView addSubview:self.valueLabel]; |
} |
- (void)dealloc{ |
[setting release]; |
[titleLabel release]; |
[valueLabel release]; |
self.valueInput = nil; |
[super dealloc]; |
} |
@end |