0

In iOS 7 the [alert addSubview]; method is not working for adding any subview on the alert view.

So I used [alert setValue:view forKey:@"accessoryView"]; to display the UIActivityIndicator on the alert view.

My questions are:

  1. Is @"accessoryView" public to the API to add the view on alert ?
  2. Will apple accept this type of behaviour ?
BoJack Horseman
  • 4,406
  • 13
  • 38
  • 70
Nandy
  • 31
  • 4
  • Check this answer. http://stackoverflow.com/a/21067447/208623 – napolux Jun 04 '14 at 10:20
  • possible duplicate of [How to add subview inside UIAlertView for iOS 7?](http://stackoverflow.com/questions/18759206/how-to-add-subview-inside-uialertview-for-ios-7) – napolux Jun 04 '14 at 10:21

1 Answers1

0

You SHOULD NOT be adding views to a UIAlertView this is a one fast track ticket to getting your app rejected from the App Store, check out the section mark as Subclassing Notes from the Apple UIAlertView Documentation

Subclassing Notes

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.

In iOS7 Apple basically re-enforced the above by making it so addSubview: actually did nothing, it is there still though because UIAlertView is a subclass of UIView and UIView can still respond to this method. Many have however written custom AlertViews check out iOS Custom AlertView for example

Community
  • 1
  • 1
Popeye
  • 11,839
  • 9
  • 58
  • 91