0

我正在开发一个 iOS 应用程序,当我在设备上尝试它时,更改视图时速度太慢。在模拟器中它工作得很好。

那是我的 viewDidLoad 代码。Y 不知道某些功能是否太繁重而无法实现。

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
    // code for 4-inch screen
    self.backImage.image = [UIImage imageNamed:@"settings-568h@2x.png"];
} else {
    // code for 3.5-inch screen
    self.backImage.image = [UIImage imageNamed:@"settings@2x.png"];
}

array = [[NSMutableArray alloc] initWithObjects:@"Object1",@"Object2",@"Object3", nil];

NSString *loadedString = [array objectAtIndex:0]; //Defalut
self.checkedIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];

NSString *savePath = [self pathOfSavingFile:@"fileSetting"];
if([[NSFileManager defaultManager] fileExistsAtPath:savePath])
{
    NSString *tempSTR = [[NSString alloc] initWithContentsOfFile:savePath encoding:5 error:nil];
    loadedString = tempSTR;
}

if([[array objectAtIndex:0] isEqualToString:loadedString]) {
    self.checkedIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
} else if ([[array objectAtIndex:1] isEqualToString:loadedString]) {
    self.checkedIndexPath = [NSIndexPath indexPathForRow:1 inSection:0];
} else if ([[array objectAtIndex:2] isEqualToString:loadedString]) {
    self.checkedIndexPath = [NSIndexPath indexPathForRow:2 inSection:0];
}

UIApplication *pNote = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:myApp];

self.titleLabel.text = NSLocalizedString(@"settingsLoc", nil);
[self.backButton     setTitle:NSLocalizedString(@"backLoc", nil)     forState:UIControlStateNormal];

[super viewDidLoad];

非常感谢你。

4

0 回答 0