I agree with commentators who said that this is not a way to do this for several reasons. First, no one likes pop-up warnings all the time. Secondly, and not applicable to your situation. Ultimately, this can lead to a rejection of the application. Apple changed the wording in the UIAlertView class description, referring to its view hierarchy as closed; And we all know how the apple feels that you are fucking in what is considered private.
From the link to the UIAlertView class:
The UIAlertView class is intended to be used as is, not subclass support. The presentation hierarchy for this class is private and should not be changed.
But since you are saying that this is a private application, this is the case here. A UIAlertView is just a subclass of UIView . Thus, all frame and border rules still apply. Here's a basic example of how to set the collector frame and alert borders to compress the dates in the collector.
// Create alert UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello" message:@"message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; // Show alert (required for sizes to be available) [alert show]; // Create date picker (could / should be an ivar) UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:CGRectMake(10, alert.bounds.size.height, 320, 216)]; // Add picker to alert [alert addSubview:picker]; // Adjust the alerts bounds alert.bounds = CGRectMake(0, 0, 320 + 20, alert.bounds.size.height + 216 + 20);
EDIT
As noted by both comments and new answers to many of the questions “How to add some questions to UIAlertView ”, this method no longer works in iOS7 and higher. This really should be taken as evidence that this is a fundamentally bad idea.
Also note the use of setValue:forKey: in the common "solution" for the "problem" due to the inability to change the hierarchy of Apple's private view. setValue:forKey: is one of those methods that attracts the attention of private API scanners. Look for an accessoryView search in the UIAlertView documentation and headers. This is not in the docs. The only related element in the headers is ivar named _accessoryView , which is marked as @private .
Again for a native or private application, I suppose everything is fine, but still.
Njones
source share