This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Set up the CV Video Camera object to bring in video to the program | |
| videoCamera = [[CvVideoCamera alloc] initWithParentView:self.imageView]; | |
| videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack; | |
| videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPresetHigh; | |
| videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait; | |
| videoCamera.defaultFPS = 30; | |
| videoCamera.grayscaleMode = NO; | |
| videoCamera.delegate = self; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Initialize location services. | |
| locationManager = [[CLLocationManager alloc] init]; | |
| [locationManager requestAlwaysAuthorization]; | |
| locationManager.delegate = self; | |
| // Accuracy constants here. These should be tested for battery optimization. | |
| locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; | |
| locationManager.distanceFilter = kCLDistanceFilterNone; | |
| [locationManager startUpdatingLocation]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CLLocationCoordinate2D mapCoordinate = ...; //user location or annot coord | |
| MKMapPoint mapPoint = MKMapPointForCoordinate(mapCoordinate); | |
| MKPolygonView *polygonView = | |
| (MKPolygonView *)[mapView viewForOverlay:polygonOverlay]; | |
| CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint]; | |
| BOOL mapCoordinateIsInPolygon = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (IBAction)showToolbarButtonPressed:(id)sender { | |
| // Set up conditional to setup toggle feature. | |
| // This conditional checks if the toolbar is invisible, and if it is, it animates the opacity to 100%, otherwise, it assumes the toolbar is visible, and animates the opacity to 0%. Code can check any other conditionals, ie. self.toolbar.isHidden == YES, etc. | |
| if (self.toolbar.alpha == 0.0f) { | |
| // Disable button | |
| [self.showToolbarButton setEnabled:NO]; | |
| // Fade toolbar in w/ Animation | |
| [UIView animateWithDuration:2.0f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MKMapRect zoomRect = MKMapRectNull; | |
| for (id <MKAnnotation> annotation in mapView.annotations) { | |
| MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate); | |
| MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0); | |
| if (MKMapRectIsNull(zoomRect)) { | |
| zoomRect = pointRect; | |
| } else { | |
| zoomRect = MKMapRectUnion(zoomRect, pointRect); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Put this in viewDidLoad where _webView is your targetted view | |
| UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; | |
| [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged]; | |
| [_webView.scrollView addSubview:refreshControl]; | |
| // Declare this method elsewhere in the implementation file | |
| -(void)handleRefresh:(UIRefreshControl *)refresh { | |
| // Code here | |
| [refresh endRefreshing]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Import these Frameworks: | |
| #import <MapKit/MapKit.h> | |
| // Include this delegate | |
| @interface ViewController () <MKMapViewDelegate> | |
| - (void)viewDidLoad | |
| { | |
| // Add this code to your preexisting viewDidLoad method |
NewerOlder