Просмотр исходного кода

1.修改iOS Apex & Drivers拍照方向不正确。

Pen Li 8 лет назад
Родитель
Сommit
ad33be6ec7

+ 2 - 2
Redant Drivers/Apex And Drivers/Camera/Camera.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -77,7 +77,7 @@
                             <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" maximumZoomScale="4" translatesAutoresizingMaskIntoConstraints="NO" id="w4v-z1-b7B">
                                 <rect key="frame" x="0.0" y="20" width="375" height="647"/>
                                 <subviews>
-                                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Z0q-fB-hKK">
+                                    <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Z0q-fB-hKK">
                                         <rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
                                     </imageView>
                                 </subviews>

+ 14 - 6
Redant Drivers/Apex And Drivers/Camera/RACameraViewController.m

@@ -67,6 +67,14 @@
     [super viewDidLayoutSubviews];
     
     self.previewLayer.frame = self.previewContainer.bounds;
+    
+    if (self.previewLayer.connection.isVideoOrientationSupported) {
+        self.previewLayer.connection.videoOrientation = [self captureVideoOrientation];
+    }
+    
+    if ([self.captureOutput connectionWithMediaType:AVMediaTypeVideo].isVideoOrientationSupported) {
+        [self.captureOutput connectionWithMediaType:AVMediaTypeVideo].videoOrientation = [self captureVideoOrientation];
+    }
 }
 
 #pragma mark - Capture
@@ -129,11 +137,6 @@
         return;
     }
     self.captureOutput = [[AVCaptureStillImageOutput alloc] init];
-    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
-    if (connection.supportsVideoOrientation) {
-        connection.videoOrientation = [self.previewLayer connection].videoOrientation;
-//        connection.videoOrientation = [self captureVideoOrientation];
-    }
     
     NSDictionary *setting = @{AVVideoCodecKey:AVVideoCodecJPEG};
     [self.captureOutput setOutputSettings:setting];
@@ -141,7 +144,12 @@
     if ([self.captureSession canAddOutput:self.captureOutput]) {
         [self.captureSession addOutput:self.captureOutput];
     }
-
+    
+    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
+    if (connection.isVideoOrientationSupported) { // addOutput之后判断,否则一直都是false
+        connection.videoOrientation = [self captureVideoOrientation];
+    }
+    
 }
 
 - (AVCaptureDevice *) videoDevicePosition:(AVCaptureDevicePosition)position {

+ 2 - 1
Redant Drivers/Apex And Drivers/Camera/RATakePhotoPreviewController.m

@@ -36,7 +36,8 @@
 }
 
 - (void)setPreImage:(UIImage *)preImage {
-    _preImage = [preImage fixOrientation];
+//    _preImage = [preImage fixOrientation];
+    _preImage = preImage;
 }
 
 //- (BOOL)prefersStatusBarHidden {

+ 9 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -26,6 +26,9 @@
 
 #import "RAProgressHUD.h"
 
+#import <AddressBook/AddressBook.h>
+//#import <Contacts/Contacts.h>
+
 
 
 @implementation RAOrderDetailViewController (TableViewDataSource)
@@ -111,7 +114,12 @@
     UIAlertAction *appleMapAction = [UIAlertAction actionWithTitle:@"Apple Map" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         
         MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
-        MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(37.782652, -122.410126) addressDictionary:nil]];
+//        MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(37.782652, -122.410126) addressDictionary:nil]];
+        
+        MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:kCLLocationCoordinate2DInvalid
+                                                                                           addressDictionary:@{
+                                                                                                               (__bridge id)kABPersonAddressStreetKey : model.location
+                                                                                                               }]];
         [MKMapItem openMapsWithItems:@[currentLocation, toLocation] launchOptions:@{
                                                                                     MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,
                                                                                     MKLaunchOptionsShowsTrafficKey: @(YES)

+ 1 - 0
Redant Drivers/Apex And Drivers/Home/RAHomeViewController+HomeTableDelegate.m

@@ -35,6 +35,7 @@
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     
     RAHomeOrderModel *order = [self orderModelForIndexPath:indexPath];
+    self.currentOrderID = order.orderID;
     [self pushDetailViewControllerForModel:order];
 }
 

+ 3 - 3
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -169,7 +169,7 @@
 
 + (NSDictionary *)requestOrderList {
     
-    sleep(3.0);
+//    sleep(3.0);
     return [self loadFakeData:@"fake_order_list.json"];
 //    return [self fakeError];
     
@@ -184,7 +184,7 @@
 
 + (NSDictionary *)requestOrderDetail:(NSString *)orderID {
     
-    sleep(3.0);
+//    sleep(3.0);
     return [self loadFakeData:@"fake_order_detail.json"];
 //    return [self fakeError];
     
@@ -198,7 +198,7 @@
 
 + (NSDictionary *)requestUpdateOrder:(NSString *)orderID driverAction:(NSInteger)action {
     
-    sleep(3.0);
+//    sleep(3.0);
     return [self loadFakeData:@"fake_order_edit.json"];
 //    return [self fakeError];