Alert View Is Showing White Rectangle in iOS7

Alert view is showing white rectangle in iOS7


now addSubview is not available in UIAlertView in iOS7

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified

As an alternative you can use SVProgressHUD.

iOS 5 UIAlertView customisation

You can't add any view as a sub view in alert view as per the IOS 7 standard. please refer apple document. (UIAlert view customization not possible in IOS 7)

Please refer:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UIAlertView.html#//apple_ref/doc/uid/TP40012857-UIAlertView-SW1

How to add subview inside UIAlertView for iOS 7?

You can really change accessoryView to customContentView in iOS7 (and it seems that in iOS8 as well) UIAlertView

[alertView setValue:customContentView forKey:@"accessoryView"];

Try this code:

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
[av setValue:v forKey:@"accessoryView"];
v.backgroundColor = [UIColor yellowColor];
[av show];

Remember that you need set custom accessoryView before the call [alertView show]

Sample Image

iOS 8: UIAlertView / UIAlertController not showing text or buttons

I got the answer to my issue. The issue was that I was using UIFont+Replacement category in my project. This was working fine on iOS 7 but on iOS 8 it was using few deprecated methods. Due to this, I don't know why, but only my alert view was not showing any labels.

Solution: Deleted the category from the project and set font through xib. Once we place the .tff file of any font in our project workspace, we see those font names in the xib under custom fonts. NO NEED TO USE UIFont+Replacement category.

How to add UIActivityIndicatorView at center of UIAlertView?

You have forgotten to take into account the indicator's width and height, when setting it's x and y position in the alertview frame.

indicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(roundf((screenRect.size.width - 50) / 2), roundf((screenRect.size.height - 50) / 2),50,50)];

EDIT: This is the exact one I typically use: (don't forget to release things, etc)

UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Loading..." message: nil delegate:self cancelButtonTitle: nil otherButtonTitles: nil];
UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(125, 50, 30, 30)];
progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[alert addSubview: progress];
[progress startAnimating];
[alert show];

Change tint color of UIAlertview and UIActionsheet buttons

As UIAlertView is deprecated You can. Use UIAlertController.

You can use tintColor property.

OLD

The UIAlertView class is intended to be used as-is and does not
support subclassing. The view hierarchy for this class is private and
must not be modified.

-From Apple Doc

You can use tintColor property or You can use Some Custom Library for that, you can find it at cocoacontrols.com.



Related Topics



Leave a reply



Submit