Skip to content

Instantly share code, notes, and snippets.

//
// DOViewController.m
// LoginForm
//
// Created by David Olesch on 4/1/14.
// Copyright (c) 2014 David Olesch. All rights reserved.
//
#import "DOViewController.h"
@davidolesch
davidolesch / gist:9309897
Created March 2, 2014 17:15
Lesson 4 presented March 4th 2014
- (void)getAndDisplayTravelTime
{
//create request
MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];
[request setSource:[[MKMapItem alloc] initWithPlacemark:self.origin]];
[request setDestination:[[MKMapItem alloc] initWithPlacemark:self.destination]];
[request setTransportType:MKDirectionsTransportTypeAutomobile];
//send request
[[[MKDirections alloc] initWithRequest:request] calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
@davidolesch
davidolesch / gist:9309876
Last active August 29, 2015 13:56
Lesson 3 presented March 4th 2014
//DORouteMapViewController interface
@property (strong, nonatomic) MKPlacemark *origin;
@property (strong, nonatomic) MKPlacemark *destination;
//this method is called while transitioning from the search view to the map view
-(void)mapFromLocation:(NSString *)fromLocation toLocation:(NSString *)toLocation
{
//geocode the from location and handle the returned placemark
[[[CLGeocoder alloc] init] geocodeAddressString:fromLocation completionHandler:^(NSArray *placemarks, NSError *error) {
//grab the first placemark and set it as the origin placemark
//DOMainViewController.m
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"1.png"]]];
//DOContactsTableViewController.h
UIImageView *backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 44)];
UIImage *backgroundImage = [[UIImage imageNamed:@"newsfeed_background.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
[backgroundView setImage:backgroundImage];
backgroundView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
[cell.contentView insertSubview:backgroundView belowSubview:cell.textLabel];