0

私はtableViewセルをクリックすると多くのView Controllerを持っています.新しいView Controllerの問題に移動します.次のビューに移動するのに時間がかかるという問題があります.サーバーからフェッチデータをロードするビューが原因である可能性があります.ロードするビュー

     - (void)viewDidLoad {

   appDelegate = (MultipleDetailViewsWithNavigatorAppDelegate *)[[UIApplication sharedApplication] delegate];

  UIImageView *bottomImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Nav.png"]];

   [bottomImageView setFrame:CGRectMake(0,690,1024,34)];
  [self.view addSubview:bottomImageView];


   UIButton *button1=[UIButton buttonWithType:UIButtonTypeCustom];
  [button1 setFrame:CGRectMake(10.0, 2.0, 88, 40.0)];
  [button1 addTarget:self action:@selector(loginPressed) forControlEvents:UIControlEventTouchUpInside];
  [button1 setImage:[UIImage imageNamed:@"logoutN.png"] forState:UIControlStateNormal];
   UIBarButtonItem *button = [[UIBarButtonItem alloc]initWithCustomView:button1];
  self.navigationItem.rightBarButtonItem = button;



self.title=@"Catalog";
popImageView.hidden=YES;
passwordLabel.hidden=YES;
userLabel.hidden=YES;
userNameTextField.hidden=YES;
userPasswordTextField.hidden=YES;
signInButton.hidden=YES;

tableView.hidden=NO;




searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
searching = NO;
letUserSelectRow = YES;

if(!categoryArray){



    categoryArray =[[NSMutableArray alloc] init];


}

if(!userArray){



    userArray =[[NSMutableArray alloc] init];


}
if(!subCategoryArray){


    subCategoryArray =[[NSMutableArray alloc] init];

}

if(!subCategoryArrayOne){


    subCategoryArrayOne =[[NSMutableArray alloc] init];


}
if(!subCategoryArrayTwo){


    subCategoryArrayTwo =[[NSMutableArray alloc] init];


}

[self setUpData];
[self setUpDataSub];
[self setUpDataSubOne];
    [self setUpDataSubTwo];
int count=[appDelegate.coffeeArray count];
NSLog(@"Arrays Content Are %d",count);
    tableView.backgroundView = nil;
[super viewDidLoad];
}

ビューを高速にロードする方法はありますか

4

1 に答える 1

0

viewDidLoad メソッドでこれらのデータセット操作を推測しているため、ビューの読み込みが高速ではありません。私はそれらがあると思います:

[self setUpData];
[self setUpDataSub];
[self setUpDataSubOne];
[self setUpDataSubTwo];

できることの 1 つは、この操作をバックグラウンド スレッドで実行するように移動することです。そのために、この操作を別の関数に移動し、それを呼び出してビューからバックグラウンドで実行するメソッドをロードしました:

-(void)dataOperations
{
[self setUpData];
[self setUpDataSub];
[self setUpDataSubOne];
[self setUpDataSubTwo];
}

viewDidLoad では、この関数をバックグラウンドで呼び出します。

[self performSelectorInBackground:@selector(dataOperations) withObject:nil];

または、次のように viewDidLoad からこれらのメソッドを直接呼び出すことができます。

[self performSelectorInBackground:@selector(setUpData) withObject:nil];
于 2013-07-08T06:40:08.607 に答える