Uistepper in Uialertview

2019-06-09 21:03发布

问题:

How can I show UIStepper in UIAlertView? Also suggest me any other alternative to show UIStepper in pop-up.

回答1:

A better way of inserting views in UIAlertView would be to add them as a subview

Try the following

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"\n\n" delegate:nil  cancelButtonTitle:@"OK" otherButtonTitles: nil];
    UIStepper* stepper = [[UIStepper alloc] init];
    stepper.frame = CGRectMake(12.0, 5.0, 100, 10);
    [alert addSubview:stepper];
    [alert show];


回答2:

Try this.. Hope it will help you

 UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(120, 20, 0, 0)];

    UIAlertView *alert =[[UIAlertView alloc]init];// you can set your frame according to ypur requirment
    [alert addSubview:stepper];
    [alert show];