开发者

Custom alertview showing on top?

I am facing a weird situation. I have a tab bar application,where i am showing a custom alertbox in a particular view.The problem is that the alertbox alway开发者_StackOverflows display on top rather than middle of screen.

I am currently using Xcode 3.2.5 & build it on iPhone simulator 4.2

Custom alertview showing on top?

Edit

-(void)createAlertbox{

    alertView = [[UIAlertView alloc] init];
    [alertView setDelegate:self];
    [alertView setTag:1];
    [alertView setTitle:@"sample"];
    [alertView setMessage:@" "];
    [alertView addButtonWithTitle:@"Enter"];

    CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0,60.0);
    [alertView setTransform: moveUp];
    ageTextField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0,25.0)];
    [ageTextField setBackgroundColor:[UIColor whiteColor]];
    [ageTextField setPlaceholder:@"Enter your Current Age"];
    ageTextField.keyboardType=UIKeyboardTypeNumberPad;
    ageTextField.delegate=self;
    [alertView addSubview:ageTextField];

    [alertView show];
    [alertView release];
    [ageTextField release]; 

}


I don't know why phix23 did't put that comment as an answer!

It's because of the transform :

CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0,60.0);
[alertView setTransform: moveUp];

You're telling the ui alert view to be 60px higher than it would otherwise be. Delete these lines and I bet it's in the center again.


Where did you get your code from - I'm assuming that because you didn't know what the transform did you have cut-and-pasted it from somewhere?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜