1

ボタンを介して CategoryAndItemController を呼び出すメイン ビュー コントローラーがあります。

CategoryAndItemController 内に 2 つの UITableViewController があります。

viewDidLoad メソッドのコードは次のとおりです。

if enter code here(categoriesController == nil) {
    categoriesController = [[CFCategoriesTableViewController alloc] init];
}
if (itemsController == nil) {
    itemsController = [[CFItemsTableViewController alloc] init];
}

[categoriesTable setDataSource:categoriesController];
[itemsTable setDataSource:itemsController];

[categoriesTable setDelegate:categoriesController];
[itemsTable setDelegate:itemsController];

categoriesController.view = categoriesController.tableView;
itemsController.view = itemsController.tableView;

必要なのは、CategoryAndItemController.view を表示し、そのビュー内に入ったらデータを要求することです。

現在、ボタンを押して CategoryAndItemController を呼び出すと、ビューはすべてのデータがフェッチされた後にのみ表示され、CategoryAndItemController.view が表示されるまでに 2 ~ 3 秒かかります。

最初に CategoryAndItemController.view を表示してから、データの読み込み中に UIActivityIndi​​catorView を追加する必要があります。

4

2 に答える 2

0

このコードをviewDidLoadに追加します

- (void)viewDidLoad
   {

      UIActivityIndicatorView *activityIndicator = [[[UIActivityIndicatorView alloc]   ini

        tWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
                activityIndicator.hidesWhenStopped = YES;
                activityIndicator.hidden = NO;
               activityIndicator.center=  self.view.center
                [activityIndicator startAnimating];
                [self.view addSubview:activityIndicator]

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

    -(void)call_progress
    {

       // web service code:

       [activityIndicator stopAnimating];
       [activityIndicator removeFromSuperview];

    }
于 2013-08-01T09:47:39.847 に答える