嘿伙计们,我迫切需要一些帮助,
我正在尝试将 UITextfield 中的数字解析为数学函数,然后将其解析为 UISlider,控制 UISlider。我已经在这里呆了 2 天,但是我无法从 UITextField 中获取数字来使 UISlider 移动,但它会自行移动。
谢谢您的帮助
这是一个片段:
include <math.h>
pragma mark - User Actions
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
CGFloat focal_length = [textField.text floatValue];
CGFloat zoom =(2*atanh(4.592/(2*focal_length))*180/M_PI);
//iPhone 5: 58.498 degrees (based upon a resolution of 3264x2448 pixels, a focal length of 4.1mm and a vertical chip size of 4.592mm)
//2*atan(4.592/(2*4.28))*180/pi = 56.423
self.picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity,zoom, zoom);
return YES;
}
- (IBAction)focal_length:(UITextField *)sender
{
CGFloat focal_length = [sender.text floatValue];
CGFloat zoom = 1 + focal_length;
//CGFloat zoom = 1 + 4*focal_length;
self.picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity,zoom, zoom);
_Slider.value = [sender.text floatValue];
}
- (IBAction)zoom:(id)sender{
UISlider *slider = (UISlider*)sender;
//CGFloat zoom = 1 + 4*slider.value;
CGFloat zoom = 1 + 4*slider.value;
// slider.value = [UITextField.text floatValue];
self.picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity,zoom, zoom);
[sender resignFirstResponder];
}