0

ネットワーク接続中にビュー ページのモーダルを設定する方法はありますか? ネットワークが接続されている場合、ページ内のすべてのコントローラーがユーザー操作に応答しないということですか?


次のようなコードを更新しました。

- (void)loadView
{
    [super loadView];
    _hudView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)];
    _hudView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    _hudView.clipsToBounds = YES;
    _hudView.layer.cornerRadius = 10.0;

    _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    _activityIndicatorView.frame = CGRectMake(65, 40, _activityIndicatorView.bounds.size.width, _activityIndicatorView.bounds.size.height);
    [_hudView addSubview:_activityIndicatorView];
    [_activityIndicatorView startAnimating];

    _captionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
    _captionLabel.backgroundColor = [UIColor clearColor];
    _captionLabel.textColor = [UIColor whiteColor];
    _captionLabel.adjustsFontSizeToFitWidth = YES;
    _captionLabel.textAlignment = UITextAlignmentCenter;
    _captionLabel.text = @"Loading...";
    [_hudView addSubview:_captionLabel];



    NSArray *buttonNames = [NSArray arrayWithObjects:@"hehe",@"xixi",nil];

    UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:buttonNames];
    segmentControl.frame = CGRectMake(0, 0, TTApplicationFrame().size.width/2, TT_ROW_HEIGHT-10); 
    segmentControl.segmentedControlStyle = UISegmentedControlStyleBar;
    segmentControl.momentary = NO;
    segmentControl.tintColor = [UIColor darkGrayColor]; 
    segmentControl.selectedSegmentIndex = 0;
    [segmentControl addTarget:self action:@selector(switchPage:) forControlEvents:UIControlEventValueChanged];
    self.navigationItem.titleView = segmentControl;
    TT_RELEASE_SAFELY(segmentControl);
    self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
    self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
    self.tableView.rowHeight = 80.f;
    self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    [self reload]; 
    [self updateView]; 
}

次のように表示します。

- (void)showLoading:(BOOL)show {
    if (show) {
        self.loadingView = _hudView;

    }
    else {        
        self.loadingView = nil;

    }
}

コメントで言ったように、UISegmentedControl のボタンをカバーすることはできませんが、ユーザーはそれらのボタンをクリックできます...

4

1 に答える 1

0

modalViewController を使用する代わりに、HUD (TTCatalogue アプリに表示される UIActivityIndi​​cators を持つ優れたビューの 1 つ) を作成して、ビューをブロックし、リクエスト中に何かが起こっていることをユーザーに通知します。それらを a で挿入するだけ[self.view addSubview:theHUDview];です。

ただし、必ずしも良い設計とは限りません。代わりに、バックグラウンドでネットワーク呼び出しを非同期に行います。

于 2011-08-16T14:22:22.507 に答える