2012年に作成された古いiOSプロジェクトを継承し、実際に古い学校の技術を使用しています。私は32ビットから64ビットに変換しました。iOSの設定ページの項目が混乱しています
設定画面では、設定項目の高さが十分ではないため、設定ページが混乱して見えることがあります。
何が起こっているのでしょうか?
このページにはコードで生成されたxibファイルはありません。
#import "GeneralSettings.h"
//preference keys
#define kGENERAL_ACCOUNT @"general_account"
#define kGENERAL_EXPAND_RESULTS @"general_expand_results"
#define kGENERAL_FINALS_ONLY @"general_finals_only"
#define kGENERAL_SEARCH_DAYS @"general_search_days"
#define kGENERAL_STARTUP @"general_startup"
@interface GeneralSettings()
@end
@implementation GeneralSettings
+ (NSString *)accountNumber {
return [[NSUserDefaults standardUserDefaults]
objectForKey:kGENERAL_ACCOUNT];
}
+ (BOOL)expandResults {
NSString *expandResults = [[NSUserDefaults standardUserDefaults]
objectForKey:kGENERAL_EXPAND_RESULTS];
return expandResults ? [expandResults boolValue] : YES;
}
+ (BOOL)finalsOnly {
return [[NSUserDefaults standardUserDefaults]
boolForKey:kGENERAL_FINALS_ONLY];
}
+ (NSInteger)numberOfDays {
NSString *numberOfDays = [[NSUserDefaults standardUserDefaults]
objectForKey:kGENERAL_SEARCH_DAYS];
if (numberOfDays) {
if (([numberOfDays integerValue] != 90) || [Globals
sharedInstance].isQA) {
return [numberOfDays integerValue];
}
//value of 90 lingering from QA session, reset to 15
[[NSUserDefaults standardUserDefaults] setValue:@"15"
forKey:kGENERAL_SEARCH_DAYS];
return 15;
}
//default value
return 7;
}
+ (NSInteger)showAtStartup {
return [[NSUserDefaults standardUserDefaults]
integerForKey:kGENERAL_STARTUP];
}
+ (void)setAccountNumber:(NSString *)accountNumber {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setValue:accountNumber forKey:kGENERAL_ACCOUNT];
[prefs synchronize];
}
+ (void)convert {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if ([prefs objectForKey:@"finalsOnly"]) {
BOOL value = [prefs boolForKey:@"finalsOnly"];
[prefs removeObjectForKey:@"finalsOnly"];
[prefs setBool:value forKey:kGENERAL_FINALS_ONLY];
[prefs synchronize];
}
if ([prefs objectForKey:@"searchDays"]) {
NSString *value = [prefs objectForKey:@"searchDays"];
int index = 2;
if ([value isEqualToString:@"1 Days"]) {
index = 0;
}
else if ([value isEqualToString:@"3 Days"]) {
index = 1;
}
else if ([value isEqualToString:@"15 Days"]) {
index = 3;
}
[prefs removeObjectForKey:@"searchDays"];
[prefs setInteger:index forKey:kGENERAL_SEARCH_DAYS];
[prefs synchronize];
}
if ([prefs objectForKey:@"showAtStartup"]) {
NSString *value = [prefs objectForKey:@"showAtStartup"];
int index = 0;
if ([value isEqualToString:@"Contacts"]) {
index = 1;
}
else if ([value isEqualToString:@"Lookup Test"]) {
index = 2;
}
[prefs removeObjectForKey:@"showAtStartup"];
[prefs setInteger:index forKey:kGENERAL_STARTUP];
[prefs synchronize];
}
}
- (id)init {
self = [super initWithTitle:xGeneralSettings withIconName:@"icon-
settings-general.png"];
if (self) {
//initialization
Globals *globals = [Globals sharedInstance];
SettingsSection *section = [self.sections objectAtIndex:0];
//add account settings section
SettingsSection *accountSection = [[[SettingsSection alloc]
initWithTitle:xAccountSettings] autorelease];
[self.sections addObject:accountSection];
//create settings
Setting *startupSetting = [[[Setting alloc]
initWithKey:kGENERAL_STARTUP withTitle:xGeneralStartupTitle
withType:pickerSetting] autorelease];
SearchDaysSetting *searchDaysSetting = [[[SearchDaysSetting alloc]
initWithKey:kGENERAL_SEARCH_DAYS withTitle:xGeneralSearchDaysTitle
withType:pickerSetting] autorelease];
Setting *finalsSetting = [[[Setting alloc]
initWithKey:kGENERAL_FINALS_ONLY withTitle:xGeneralFinalsOnlyTitle
withType:toggleSetting] autorelease];
Setting *expandSetting = [[[Setting alloc]
initWithKey:kGENERAL_EXPAND_RESULTS
withTitle:xGeneralExpandResultsTitle withType:toggleSetting] autorelease];
AccountSetting *accountSetting = [[[AccountSetting alloc]
initWithKey:kGENERAL_ACCOUNT withTitle:xGeneralAccountTitle
withType:pickerSetting] autorelease];
//set setting parameters
[startupSetting setPickerValuesFromString:xGeneralStartupValues
withDefaultValue:0];
[searchDaysSetting
setPickerValuesFromString:xGeneralSearchDaysValues withDefaultValue:2];
[finalsSetting setToggle:NO
withSummary:xGeneralFinalsOnlySummary];
[expandSetting setToggle:YES
withSummary:xGeneralExpandResultsSummary];
[accountSetting setPickerValues:[globals allAccounts]
withDefaultValue:[globals defaultAccount]];
if ([Globals sharedInstance].isQA) {
[searchDaysSetting.pickerValues addObject:@"90 Days"];
}
//add settings to sections
[section.settings addObject:startupSetting];
[section.settings addObject:searchDaysSetting];
[section.settings addObject:finalsSetting];
[section.settings addObject:expandSetting];
[accountSection.settings addObject:accountSetting];
}
return self;
}
@end
#pragma mark - AccountSetting class
@implementation AccountSetting
- (NSInteger)intValue {
NSArray *picklist = self.pickerValues;
NSString *value = [self stringValue];
//return the index of our value
for (int i = 0; i < picklist.count; i++) {
if ([[picklist objectAtIndex:i] isEqualToString:value]) {
return i;
}
}
return [super intValue];
}
- (void)setInteger:(NSInteger)index shouldSave:(BOOL)saveValue {
NSArray *picklist = self.pickerValues;
if ((index > -1) && (index < picklist.count)) {
//save the value determined by this index
[self setString:[picklist objectAtIndex:index]
shouldSave:saveValue];
}
}
@end
#pragma mark - AccountSetting class
@implementation SearchDaysSetting
- (NSInteger)intValue {
//return the index of our value
switch ([super intValue]) {
case 1:
return 0;
case 3:
return 1;
case 7:
return 2;
case 15:
return 3;
case 90:
return [self pickerValues].count - 1; //safe return of assumed index, which might not exist
}
return [[self defaultValue] integerValue];
}
- (void)setInteger:(NSInteger)index shouldSave:(BOOL)saveValue {
NSInteger numberOfDays = 7;
//save the value determined by this index
switch (index) {
case 0:
numberOfDays = 1;
break;
case 1:
numberOfDays = 3;
break;
case 2:
numberOfDays = 7;
break;
case 3:
numberOfDays = 15;
break;
case 4:
numberOfDays = 90;
break;
}
[super setInteger:numberOfDays shouldSave:saveValue];
}
@end
あなたはセルの高さを設定してみましたか? – trungduc
tableViewはありませんか?はいの場合は、コードを表示してください。32/64ビット問題のためにコードを表示しても驚きません。 – Larme
投稿されたコードは、写真のテーブルビューと何が関係していますか?転記されたコードを、テーブルビューの作成および移入に関連するコードに置き換えます。 – rmaddy