UIAlertView in ipad4.2

Discussion in 'iPhone/iPad Programming' started by AbhishekApple, Jan 10, 2011.

  1. macrumors member

    Joined:
    Aug 5, 2010
    #1
    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!!!!!!
     
  2. thread starter macrumors member

    Joined:
    Aug 5, 2010
    #2
    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
     
  3. macrumors newbie

    Joined:
    Aug 11, 2010
    Location:
    Jalisco, México
    #3
    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...
     

Share This Page