I know that there has been one question about this but it is not clear to me. I want to add a UISlider to UIAlertView. In the UIAlertView, I also add one UILabel to show the value of UISlider. What I have been done so far is:
UIAlertView *alert= [[UIAlertView alloc]
initWithTitle: @"Set delay"
message: @" "
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
UISlider *mySlider=[[UISlider alloc] initWithFrame:CGRectMake(20, 50, 200, 20)];
mySlider.maximumValue=10.00;
mySlider.minimumValue=1.00;
UILabel *myLabel=[[UILabel alloc] initWithFrame:CGRectMake(220, 50, 50, 40)];
int x=.........;//x should get value of mySlider
[myLabel setText:[NSString stringWithFormat:@"%d",x]];
[alert addSubview:myLabel];
[alert addSubview:mySlider];
[alert show];
[alert release];
so I want variable x to get value of mySlider and the myLabel will show the value of x. I get stuck at this point. Any suggestion is really appreciated.
Here what you need to do:
UILabelglobal, that mean declare it on the header file (this is to reach the label easily).Then add a target to the slider, with
ValueChangedevent.next, implement the
sliderHandlermethod:That will work with you.