0

uitableview を持つ uipopovercontroller があり、uitableview メソッドの didselectrowatindexpath メソッドで uiactivityindicatorview のアニメーション化を開始したいと考えています。これが私のコードです。

-(IBAction)btnA_Clicked:(id)sender{

    self.objuiviewCon = [[myuiviewController alloc] initWithNibName:@"myuiviewController" bundle:nil];
    [self.objuiviewCon setDelegate:self];

    self.ObjApopCon = [[UIPopoverController alloc] initWithContentViewController:self.objuiviewCon];
    [self.ObjApopCon setPopoverContentSize:CGSizeMake(self.objuiviewCon.view.frame.size.width, self.objuiviewCon.view.frame.size.height)];
    [self.ObjApopCon presentPopoverFromBarButtonItem:btnA permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}

@interface myuiviewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{

IBOutlet UITableView *tblList;

IBOutlet UIActivityIndicatorView *actiIndi;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [myarr count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    NSLog(@"cell called");

    cell.textLabel.text = [myarr objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"didSelectRowAtIndexPath called");
    [actiIndi startAnimating];
}

インターフェイスビルダーとデリゲートで接続されているすべての iboutle も設定されます。しかし、私の問題は、didSelectRowAtIndexPath メソッドが呼び出されていますが、アクティビティインジケーターがアニメーション化されていないことです。

プロトコルを使用してテーブル ビューの行をクリックすると webservice を呼び出すので、webservice の出力を取得するまで uiactivityindicatorview をアニメーション化する必要があります。

任意の提案をいただければ幸いです。

4

2 に答える 2

0

アクティビティとテーブルのビューを確認すると、UIActivityIndi​​cator が UITableView の背後にある可能性があります。また、非表示になっていないことも確認してください

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"didSelectRowAtIndexPath called");
    [tableview bringSubviewToFront:actiIndi];
    [actiIndi startAnimating];
}
于 2012-07-18T04:44:00.357 に答える
0

あなたが言っていることについては、didSelectRowAtIndexPath: にいくつかのコードがあります。つまり、そこで呼び出されたメソッドから webservice を呼び出しています。

すべての問題は、Web サービスを同期的に呼び出していることだと思います。ユーザー インターフェイスのすべての変更は、メソッドが終了した後にのみ機能することに注意してください。そのため、メイン インターフェイス ループに制御を戻さない場合、startAnimating は何もしません。

解決策は、次の代わりに、webservice を呼び出すメソッドを呼び出すときです。

[actiIndi startAnimating];
[self callWebservice:fooObject];

これを書きます:

[actiIndi startAnimating];
[self performSelector:@selector(callWebservice:) withObject:fooObject afterDelay:0.0];

その後、制御をメイン ループに戻すと、アクティビティ インジケーターが回転を開始し、できるだけ早く他のメソッドが呼び出されます。

于 2012-07-18T04:44:33.890 に答える