Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThank you for your answer, JFS! I'm not sure if I grabbed your idea.. It's just that I'm still very new at this Xcode thing, and I don't have yet the clear big picture of how should I really work.. I don't want to develop a bad habit of making patches to cover the holes in my program.. So many tutorials and books to study, but I can't wait to finish all of those materials first.. I hope you understand what I meant..
      singulars
    2. COWow! Thanks for writing it down for me.. I get your idea of passing the property.. I've tried it, and I got an error message said that Xcode couldn't find the property on that object even though I had imported the UI custom class and synthesized the property.. Any idea what went wrong? Another question is about the NSNumber object that you created, does it have to be an object so that it can have the retain on its property to be passed along classes? I tried to pass CGpoint property but I couldn't, I thought it was because it wasn't an object? Forgive my cluttered mind, hehe..
      singulars
    3. COIt's hard to tell where the issue is without the code. Did you bind the UIView to the ViewController and did you set the custom class to UIView and to UIViewController? The value doesn't have to be an object it can be a primitive as well. But be aware that `CGPoint` is not just an var `The data structure CGPoint represents a point in a two-dimensional coordinate system.`
      singulars
 

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