Assignment #3 Task #8

Please note, this blog entry is from a previous course. You might want to check out the current one.

Make your Calculator work on the iPad too (in the same application, i.e., a Universal application) by having two storyboards, one for the iPhone (described above) and one for the iPad that uses a UISplitViewController to present your old Calculator MVC on the left of the screen (or in a popover) and your new graphing MVC on the right.

We start by changing Devices in in the Targets Summary tab from iPhone to Universal, rename the existing storyboard to iPhone.Storyboard and adjust the settings for the iPhone Deplayment Info accordingly.

Create a new storyboard using File -> New -> File… -> User Interface -> iPad and adjust the settings for the iPad Deplayment Info to the new storyboard.
Continue reading “Assignment #3 Task #8”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Lecture #7: iPad Apps

Please note, this blog entry is from a previous course. You might want to check out the current one.

Lecture seven is named “7. iPad Apps (October 18, 2011)” and can be found at iTunes. Its slides are available at Stanford.

It starts by discussing UIToolbar and its UIBarButtonItems which are stored in an NSArray *toolbarItems. A bottom toolbar – which is hidden by default – can be made visible via storyboard or setting its @property toolbarHidden to NO.
Continue reading “Lecture #7: iPad Apps”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #10

Please note, this blog entry is from a previous course. You might want to check out the current one.

Once the user picks a scale by pinching or a new origin by panning or tapping, the new value should be stored in NSUserDefaults so that the scale and origin persist as new programs are graphed and even through relaunchings of your program.

When we store the scale in setScale as string:

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];    
    [defaults setFloat:self.scale 
                forKey:[NSString stringWithFormat:@"graphViewScale%i", 
                        self.graphView.tag]];
    [defaults synchronize];    
}

Continue reading “Assignment #3 Task #10”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #9

Please note, this blog entry is from a previous course. You might want to check out the current one.

Since we need lecture #7 for task #8, we will skip that one for now and continue with task #9:

You do not have to support rotation on all devices, but on the devices where you do support it, the user-interface should look good in all cases (so get your struts and springs right in your storyboard(s)).

However for now we just send the mode of the GraphView to Redraw in the storyboard.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #7

Please note, this blog entry is from a previous course. You might want to check out the current one.

Support the following gestures inside your graphing view:

  • Pinching (adjusts your view’s scale).
  • Panning (moves the entire graph, including axes, to follow the touch around).
  • Triple-tapping (moves the origin of the graph to the point of the triple-tap).

We add the actual functions to the view, where we

  • adjust the scale of the data source when we pinch,
  • adjust the origin of the data source when we pan or center.

Continue reading “Assignment #3 Task #7”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #6

Please note, this blog entry is from a previous course. You might want to check out the current one.

Your graphing UIView must be generic and reusable (i.e. it should be a generic x-y graphing class and know nothing about a CalculatorBrain). Use a protocol to get the graphing view’s data because Views should not own their data.

Basically we need a way to calculate an y value for a given x value, and to know where we want to place the graph and the size of the graph, which we define as protocol:

@protocol GraphViewDataSource
- (id)calculateYValueFromXValue:(double)xValue; // NSNumber or string with error
@property (nonatomic) CGFloat scale; // 1 = 100%
@property (nonatomic) CGPoint origin; // point to place in the middle of the screen
@end
...
@property (nonatomic, weak) IBOutlet id <GraphViewDataSource> dataSource;
....

Continue reading “Assignment #3 Task #6”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #5

Please note, this blog entry is from a previous course. You might want to check out the current one.

To implement your new MVC, you must write a custom graphing View which must display the axes of the graph in addition to the plot of the program. Code will be provided on the class website which will draw axes with an origin at a given point and with a given scale, so you will not have to write the Core Graphics code for the axes, only for the graphing of the program itself. You probably will want to examine the provided axes-drawing code to understand how the scaling works before you do this or any of the following Required Tasks.

The mentioned code is available for download at Stanford. Add it to your project and create a new view class e.g. GraphView as subclass from UIView.
Continue reading “Assignment #3 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail