Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>A method in the UIViewController should recognize when the slider values changes</li> <li>the same method should trigger another methode within the UIViewController to update/recalculate the sine function values (e.g. creating an value array)</li> <li>at the end of the update-methode the necessary values are transferred to the UIView via an outlet from UIViewController to the UIView (the UIView is an property of the UIViewController)</li> <li>the UIView is drawing the new sine-function in draw rect</li> </ol> <p>Edit 1: your ViewController.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @class YourGraphUIView; // that's you view where you draw @interface ResultViewController: UIViewController @property (weak, nonatomic) IBOutlet UISlider *valueFromSlider; //bound to your UISlider @property (weak) IBOutlet YourGraphUIView *yourGraphUIView; //bound to your costumUIView @property (nonatomic, retain) NSNumber *graphValue; - (IBAction)takeSliderValue:(id)sender; //bound to your UISlider @end </code></pre> <p>your ViewController.m:</p> <pre><code>#import "ResultViewController.h" #import "YourGraphUIView.h" @interface ResultViewController () @end @implementation ResultViewController @synthesize yourGraphUIView, valueFromSlider, graphValue; - (IBAction)takeSliderValue:(UISlider *)sender{ graphValue = [NSNumber numberWithDouble:[(double)sender.value]]; //takes value from UISlider yourGraphUIView.graphValue = graphValue; //gives the value to the yourGraphUIView [self.yourGraphUIView setNeedsDisplay] //&lt;--- important to redraw UIView after changes } end </code></pre> <p>your YourGraphUIView.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface YourGraphUIView : UIView @property(nonatomic, retain)NSNumber *graphValue; - (void)drawRect:(CGRect)dirtyRect; @end </code></pre> <p>your YourGraphUIView.m:</p> <pre><code>#import "YourGraphUIView.h" @implementation YoutGraphUIView @synthesize graphValue; //... init, draw rect with using the graphValue for calculating and updating the graph end; </code></pre> <p>I hope this helped. You should have a look how to build the GUI and how to connect the UIViews. You need to set the custom classes for the ViewController and the YourGraphUIView as well. Good luck!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload