Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AbhishekApple

macrumors member
Original poster
Aug 5, 2010
86
0
I had added a textfield in alertview which displayed properly in 3.2 but same code(coordinates) is creating problem in 4.2

Code:
	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" 
						  message:[COLOR="Red"]@"\n\n\n"[/COLOR]
						  delegate:self
						  cancelButtonTitle:@"Cancel"
						  otherButtonTitles:@"Button1",@"Button2", nil];
	
	alert.tag =11;
	[COLOR="red"][alert addSubview:txtFilenm];[/COLOR]
	[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!!!!!!
 
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..
Thanks
 
Is better solutions subclass AlertView

Maybe a better solution is subclass UIAlertView.

Code:
@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);
		}
	}	
}

@end

Sorry mi english is bad...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.