开发者

uitextview should reflect the changes as the uislider is moved horizontally

i took a viewbased application and i placed a uislider and a uitextview on the controller's view.my requirement is as i move the slider horizontally the changes should continuously reflect in the textview.and if i enter a value in the textview within the range of sli开发者_开发百科der,the slider should move to the respective position taking value from the textview.

tnx in advance dinakar


Add a selector to the slider as follows,

[slider addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged];

In the function sliderChanged code as follows,

textView.text= [NSString stringWithFormat:@"%.2f%%", slider.value];

Similarly, in UITextView delegate method

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
slider.value=[textView.text floatValue];
return YES;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜