2

Web サービスの呼び出し中に進行状況インジケーター ビューでアラートを呼び出します。次のようにアラート ビューを設定しています。

    [self.activityIndicatorView setHidden:NO];
self.alertView = [[UIAlertView alloc] initWithTitle:@"Sending Login Request.."
                                       message:@"\n"
                                      delegate:self
                             cancelButtonTitle:nil
                             otherButtonTitles:nil];

self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.activityIndicatorView.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
[self.alertView addSubview:self.activityIndicatorView];
[self.activityIndicatorView startAnimating];
[self.alertView show];

後でログインに失敗した場合は、self.alertView を閉じずに、アラート ビューに「OK」ボタンを配置し、self.alertView の新しいインスタンスを再度表示します。次のようなものです。

if (isThereErrorFromJsonResp) {
    [self.activityIndicatorView stopAnimating];
    [self.activityIndicatorView removeFromSuperview];
    self.activityIndicatorView = nil;
    [self.alertView setTitle:isThereErrorFromJsonResp];
    //here i want to show ok button how?
    return;
}

では、OKボタンをどのように配置すればよいでしょうか。なにか提案を?

4

3 に答える 3

-1

このコードを試してください:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Logout in offline mode may cause of data lose. Do you still want to logout?" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES",nil];
    alert.tag=11;
    [alert show];
    [self performSelector:@selector(go:) withObject:alert afterDelay:1.0];


-(void)go:(UIAlertView*)alert
{
    UIButton *b = (UIButton*)[alert viewWithTag:1];
    b.titleLabel.text = @"test";

}

最初に「OK」ボタンを追加する必要があります。そして、そのプロパティを として設定しますHidden = TRUE。そしてgoメソッドでプロパティを設定しますHidden = FALSE

于 2013-05-31T14:11:25.003 に答える