View Full Version : UIAlertView in ipad4.2

Jan 11, 2011, 12:50 AM
I had added a textfield in alertview which displayed properly in 3.2 but same code(coordinates) is creating problem in 4.2

txtFilenm = [[UITextField alloc]initWithFrame:CGRectMake(15, 70, 255, 30)];
txtFilenm.placeholder = @"Catalog Name";
txtFilenm.borderStyle = UITextBorderStyleRoundedRect;
txtFilenm.delegate = self;

UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Enter catalog name"
otherButtonTitles:@"Button1",@"Button2", nil];

alert.tag =11;
[alert addSubview:txtFilenm];
[alert show];
[alert release];

The textfield fits in the space created by newline ("\n\n\n") in 3.2 but in 4.2 the space is not created when i add the textfield.... the Button1 comes jst below the alerttitle then the textfield overlapping some part of Button1 n followed by other buttons ....

If i don't add the textfield in alert view the space is created!!!!!!

Jan 13, 2011, 02:07 AM
no one came across this issue.....
If u didn't get the issue please jst copy the code and execute it in 3.2 & 4.2 iossdk for ipad simulator..

Jan 16, 2011, 10:59 AM
Maybe a better solution is subclass UIAlertView.

@implementation Alert

-(void)setFrame:(CGRect)nFrame {
CGFloat newHeightNeeded = 250;
[super setFrame:CGRectMake(nFrame.origin.x, nFrame.origin.y, nFrame.size.width, newHeightNeeded)];

-(void)layoutSubviews {
CGFloat newHeightNeeded = 250;
CGFloat originalHeight = 120;
for (UIView *tempo in self.subviews) {
if ([[[tempo class] description] isEqualToString:@"UIThreePartButton"]) {
tempo.frame = CGRectMake(tempo.frame.origin.x, tempo.bounds.size.height + (newHeightNeeded-originalHeight), tempo.frame.size.width, tempo.frame.size.height);


Sorry mi english is bad...