2016-04-05 7 views
0

UIAlertViewローディングインジケータはほとんどオフサイドですか?私は次のコードしている

_loadingAlert = [[UIAlertView alloc] initWithTitle:ALERT_TITLE_LOADING 
              message:ALERT_MESSAGE_LOADING 
              delegate:nil 
           cancelButtonTitle:nil 
           otherButtonTitles:nil]; 

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 
[indicator startAnimating]; 

[_loadingAlert setValue:indicator forKey:@"accessoryView"]; 
[_loadingAlert show]; 

結果:

enter image description here

私の目的は、内部のロードインジケータ付きalertviewを表示することですが、結果は添付のスクリーンショットのようになります。誰でも知っている?

+0

あなたは 'UIAlertView'がしばらく非難されていますか?代わりに 'UIAlertController'を使うべきです。 – rmaddy

+0

はい、私は注意しますが、私はまだiOS 7をサポートする必要があります。 – Rendy

+0

下部に挿入図があるカスタム表示を試してください。進行状況表示には表示されません。 –

答えて

0

(@ A-ライブにより示唆されるように)このコードで試してみてください、あなたは活動の指標の下でより多くのスペースを追加するためにパディング値を調整することができます。

_loadingAlert = [[UIAlertView alloc] initWithTitle:ALERT_TITLE_LOADING 
              message:ALERT_MESSAGE_LOADING 
              delegate:nil 
           cancelButtonTitle:nil 
           otherButtonTitles:nil]; 

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 
indicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 
indicator.translatesAutoresizingMaskIntoConstraints = YES; 
[indicator startAnimating]; 

CGFloat padding = 15; 
UIView *indicatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, indicator.frame.size.width, indicator.frame.size.width+padding)]; 
[indicatorView addSubview:indicator]; 

[_loadingAlert setValue:indicatorView forKey:@"accessoryView"]; 
[_loadingAlert show]; 
+0

これは魅力的です!ありがとう! – Rendy

0

私はあなたが望むものとまったく同じように見えるので、MBProgressHUDココアポッドを試してみることをお勧めします。また、iOS 6+をサポートします。

https://github.com/jdg/MBProgressHUD

enter image description here

+0

私はUIAlertViewと似ていますが、私のクライアントはMBProgressHUDレイアウトを好まないのです。 – Rendy

関連する問題