Assignment #3 Extra Task #1

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

In the Hints section it is noted that you are allowed to draw your graph by drawing a line from each point to the next point. Clearly if your function were discontinuous (e.g. 1/x) or if you had zoomed out so far that drawing a line between points would be jumping over a lot of changes in y, this would give misleading results to the user. The best thing would probably be to simply draw dots at each coordinate you calculate. This would not help much with the zoomed-out-too-far problem, but it would certainly be more accurate on discontinuous functions. It is up to you to figure out how to draw a dot at a point with Core Graphics.

For the mandatory tasks we connected the dots of every calculated point. Now we must draws, where there is no such drawing function in iOS, thus we draw small rectangles:

CGContextFillRect(context, 
    CGRectMake([self xPointFromPixel:xPixel inRect:area] - 0.5, 
    [self yPointFromValue:y inRect:area originAtPoint:origin scale:scale] - 0.5, 1.0 , 1.0)
);
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Finished Tasks

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

The complete code of the mandatory tasks of assignment #3 can be found at github.

Addendum Task #7

The previously shown code for the pinch: method would zoom using the origin of the axis as center point thus moving a graph out of view if the currently shown area is not close to the origin. To provide a proper zoom function where the zoom happens centered to the touching point the origin has to adjusted as well as the scale:
Continue reading “Assignment #3 Finished Tasks”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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