Commit 1fe6744e authored by yuzheng.tz's avatar yuzheng.tz

Demo页支持横屏;支持视频&gif图片多选;支持同时选择图片/视频/gif图

parent 39467b90
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
...@@ -21,13 +21,11 @@ ...@@ -21,13 +21,11 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4Ae-5T-gEc" userLabel="TopContentView"> <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="AMD-xf-cz2">
<rect key="frame" x="0.0" y="0.0" width="320" height="405"/> <rect key="frame" x="0.0" y="0.0" width="375" height="440"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="obE-hs-XLa" userLabel="View1"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="obE-hs-XLa" userLabel="View1">
<rect key="frame" x="0.0" y="15" width="320" height="35"/> <rect key="frame" x="0.0" y="20" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jpa-B9-8n6"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jpa-B9-8n6">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -45,10 +43,12 @@ ...@@ -45,10 +43,12 @@
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="35" id="RuS-Zw-ecY"/>
</constraints>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wWK-ob-W4A" userLabel="View2"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wWK-ob-W4A" userLabel="View2">
<rect key="frame" x="0.0" y="55" width="320" height="35"/> <rect key="frame" x="0.0" y="55" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Rbt-bh-r0x"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Rbt-bh-r0x">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -64,9 +64,8 @@ ...@@ -64,9 +64,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kJv-DR-NlY" userLabel="View3"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kJv-DR-NlY" userLabel="View3">
<rect key="frame" x="0.0" y="90" width="320" height="35"/> <rect key="frame" x="0.0" y="90" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="a58-aK-ZB0"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="a58-aK-ZB0">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -85,9 +84,8 @@ ...@@ -85,9 +84,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Z20-6k-hhA" userLabel="View4"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Z20-6k-hhA" userLabel="View4">
<rect key="frame" x="0.0" y="125" width="320" height="35"/> <rect key="frame" x="0.0" y="125" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="iRQ-aE-1KG"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="iRQ-aE-1KG">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -106,9 +104,8 @@ ...@@ -106,9 +104,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jKt-h1-BC7" userLabel="View5"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jKt-h1-BC7" userLabel="View5">
<rect key="frame" x="0.0" y="195" width="320" height="35"/> <rect key="frame" x="0.0" y="160" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4L3-Da-pcd"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4L3-Da-pcd">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -127,9 +124,29 @@ ...@@ -127,9 +124,29 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Qrr-87-KzM" userLabel="View7"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gde-hr-2Sy" userLabel="View6">
<rect key="frame" x="0.0" y="230" width="320" height="35"/> <rect key="frame" x="0.0" y="195" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="zLj-vc-Xwz">
<rect key="frame" x="225" y="2" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="allowPickingGifSwitchClick:" destination="BYZ-38-t0r" eventType="valueChanged" id="O9W-7a-uc8"/>
<action selector="allowPickingOriginPhotoSwitchClick:" destination="BYZ-38-t0r" eventType="valueChanged" id="Y1n-2W-q5O"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="允许选择Gif图片" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ly2-uJ-7DN">
<rect key="frame" x="0.0" y="0.0" width="200" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qrr-87-KzM" userLabel="View7">
<rect key="frame" x="0.0" y="230" width="375" height="35"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="uHt-bT-lBZ"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="uHt-bT-lBZ">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -148,9 +165,8 @@ ...@@ -148,9 +165,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PA2-zk-4Ey" userLabel="View8"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PA2-zk-4Ey" userLabel="View8">
<rect key="frame" x="0.0" y="265" width="320" height="35"/> <rect key="frame" x="0.0" y="265" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="照片最大可选张数" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rK3-1U-kcW"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="照片最大可选张数" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rK3-1U-kcW">
<rect key="frame" x="0.0" y="0.0" width="200" height="35"/> <rect key="frame" x="0.0" y="0.0" width="200" height="35"/>
...@@ -168,9 +184,8 @@ ...@@ -168,9 +184,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VUP-wm-Ah2" userLabel="View9"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VUP-wm-Ah2" userLabel="View9">
<rect key="frame" x="0.0" y="300" width="320" height="35"/> <rect key="frame" x="0.0" y="300" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="每行展示照片张数" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fbH-6q-oeE"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="每行展示照片张数" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fbH-6q-oeE">
<rect key="frame" x="0.0" y="0.0" width="200" height="35"/> <rect key="frame" x="0.0" y="0.0" width="200" height="35"/>
...@@ -188,9 +203,8 @@ ...@@ -188,9 +203,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="92q-n9-Zwf" userLabel="View10"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="92q-n9-Zwf" userLabel="View10">
<rect key="frame" x="0.0" y="335" width="320" height="35"/> <rect key="frame" x="0.0" y="335" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="0ju-HJ-A06"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="0ju-HJ-A06">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -209,9 +223,8 @@ ...@@ -209,9 +223,8 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uex-bO-uvg" userLabel="View11"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uex-bO-uvg" userLabel="View11">
<rect key="frame" x="0.0" y="370" width="320" height="35"/> <rect key="frame" x="0.0" y="370" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="hsH-wt-l1R"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="hsH-wt-l1R">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
...@@ -230,19 +243,17 @@ ...@@ -230,19 +243,17 @@
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gde-hr-2Sy" userLabel="View6"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kBC-oD-k6h" userLabel="View12">
<rect key="frame" x="0.0" y="160" width="320" height="35"/> <rect key="frame" x="0.0" y="405" width="375" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="zLj-vc-Xwz"> <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="edM-ah-5KZ">
<rect key="frame" x="225" y="2" width="51" height="31"/> <rect key="frame" x="225" y="2" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections> <connections>
<action selector="allowPickingGifSwitchClick:" destination="BYZ-38-t0r" eventType="valueChanged" id="O9W-7a-uc8"/> <action selector="allowPickingMultipleVideoSwitchClick:" destination="BYZ-38-t0r" eventType="valueChanged" id="auh-9d-aAW"/>
<action selector="allowPickingOriginPhotoSwitchClick:" destination="BYZ-38-t0r" eventType="valueChanged" id="Y1n-2W-q5O"/>
</connections> </connections>
</switch> </switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="允许选择Gif图片" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ly2-uJ-7DN"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="允许多选视频/GIF图片" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7q9-aI-kbz">
<rect key="frame" x="0.0" y="0.0" width="200" height="35"/> <rect key="frame" x="0.0" y="0.0" width="200" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/> <fontDescription key="fontDescription" type="system" pointSize="15"/>
...@@ -253,19 +264,78 @@ ...@@ -253,19 +264,78 @@
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
</subviews> </subviews>
</view> <constraints>
<constraint firstItem="VUP-wm-Ah2" firstAttribute="leading" secondItem="PA2-zk-4Ey" secondAttribute="leading" id="1iv-97-UAf"/>
<constraint firstItem="92q-n9-Zwf" firstAttribute="trailing" secondItem="VUP-wm-Ah2" secondAttribute="trailing" id="2dI-dy-w3s"/>
<constraint firstItem="PA2-zk-4Ey" firstAttribute="trailing" secondItem="Qrr-87-KzM" secondAttribute="trailing" id="3up-87-K1l"/>
<constraint firstItem="VUP-wm-Ah2" firstAttribute="top" secondItem="PA2-zk-4Ey" secondAttribute="bottom" id="3wW-Pg-fzS"/>
<constraint firstItem="Z20-6k-hhA" firstAttribute="leading" secondItem="kJv-DR-NlY" secondAttribute="leading" id="9l0-Jl-AUA"/>
<constraint firstItem="Qrr-87-KzM" firstAttribute="height" secondItem="gde-hr-2Sy" secondAttribute="height" id="ClL-Ck-Dcn"/>
<constraint firstItem="92q-n9-Zwf" firstAttribute="leading" secondItem="VUP-wm-Ah2" secondAttribute="leading" id="FGD-bj-L3J"/>
<constraint firstItem="wWK-ob-W4A" firstAttribute="height" secondItem="obE-hs-XLa" secondAttribute="height" id="HFb-Z1-0pm"/>
<constraint firstItem="VUP-wm-Ah2" firstAttribute="trailing" secondItem="PA2-zk-4Ey" secondAttribute="trailing" id="JFl-1c-hQh"/>
<constraint firstItem="gde-hr-2Sy" firstAttribute="height" secondItem="jKt-h1-BC7" secondAttribute="height" id="KrA-dv-SzU"/>
<constraint firstItem="PA2-zk-4Ey" firstAttribute="leading" secondItem="Qrr-87-KzM" secondAttribute="leading" id="NLP-pQ-Qgy"/>
<constraint firstItem="92q-n9-Zwf" firstAttribute="top" secondItem="VUP-wm-Ah2" secondAttribute="bottom" id="NoR-J2-mVI"/>
<constraint firstItem="wWK-ob-W4A" firstAttribute="top" secondItem="obE-hs-XLa" secondAttribute="bottom" id="PZa-2b-GlH"/>
<constraint firstItem="PA2-zk-4Ey" firstAttribute="top" secondItem="Qrr-87-KzM" secondAttribute="bottom" id="QoI-na-E3C"/>
<constraint firstItem="wWK-ob-W4A" firstAttribute="leading" secondItem="obE-hs-XLa" secondAttribute="leading" id="R0F-K3-Hve"/>
<constraint firstItem="Z20-6k-hhA" firstAttribute="top" secondItem="kJv-DR-NlY" secondAttribute="bottom" id="T4D-dN-Lgh"/>
<constraint firstItem="PA2-zk-4Ey" firstAttribute="height" secondItem="Qrr-87-KzM" secondAttribute="height" id="TES-KZ-ed7"/>
<constraint firstItem="jKt-h1-BC7" firstAttribute="leading" secondItem="Z20-6k-hhA" secondAttribute="leading" id="VGe-vf-MfL"/>
<constraint firstItem="uex-bO-uvg" firstAttribute="top" secondItem="92q-n9-Zwf" secondAttribute="bottom" id="Vae-Me-t4r"/>
<constraint firstItem="kJv-DR-NlY" firstAttribute="leading" secondItem="wWK-ob-W4A" secondAttribute="leading" id="Wmr-AU-Xuo"/>
<constraint firstItem="jKt-h1-BC7" firstAttribute="trailing" secondItem="Z20-6k-hhA" secondAttribute="trailing" id="WwT-Gk-NVH"/>
<constraint firstItem="gde-hr-2Sy" firstAttribute="trailing" secondItem="jKt-h1-BC7" secondAttribute="trailing" id="Xih-PA-4s3"/>
<constraint firstItem="Qrr-87-KzM" firstAttribute="leading" secondItem="gde-hr-2Sy" secondAttribute="leading" id="Zb4-47-UJy"/>
<constraint firstItem="kBC-oD-k6h" firstAttribute="top" secondItem="uex-bO-uvg" secondAttribute="bottom" id="b6r-9M-h1g"/>
<constraint firstItem="Z20-6k-hhA" firstAttribute="height" secondItem="kJv-DR-NlY" secondAttribute="height" id="cSa-cz-LpU"/>
<constraint firstItem="Qrr-87-KzM" firstAttribute="top" secondItem="jKt-h1-BC7" secondAttribute="bottom" constant="35" id="eMB-pt-F7l"/>
<constraint firstItem="gde-hr-2Sy" firstAttribute="top" secondItem="jKt-h1-BC7" secondAttribute="bottom" id="eqU-F1-2IQ"/>
<constraint firstItem="jKt-h1-BC7" firstAttribute="top" secondItem="Z20-6k-hhA" secondAttribute="bottom" id="gEr-Zu-lDh"/>
<constraint firstItem="VUP-wm-Ah2" firstAttribute="height" secondItem="PA2-zk-4Ey" secondAttribute="height" id="hDo-rF-XEe"/>
<constraint firstItem="obE-hs-XLa" firstAttribute="leading" secondItem="AMD-xf-cz2" secondAttribute="leading" id="hDy-MM-w5g"/>
<constraint firstItem="uex-bO-uvg" firstAttribute="height" secondItem="92q-n9-Zwf" secondAttribute="height" id="hMH-pK-i1M"/>
<constraint firstItem="kJv-DR-NlY" firstAttribute="top" secondItem="wWK-ob-W4A" secondAttribute="bottom" id="i27-SM-wgc"/>
<constraint firstItem="kBC-oD-k6h" firstAttribute="height" secondItem="uex-bO-uvg" secondAttribute="height" id="iWw-4K-Ssi"/>
<constraint firstItem="gde-hr-2Sy" firstAttribute="leading" secondItem="jKt-h1-BC7" secondAttribute="leading" id="ikB-6o-XrM"/>
<constraint firstItem="kBC-oD-k6h" firstAttribute="trailing" secondItem="uex-bO-uvg" secondAttribute="trailing" id="jDo-vK-PhT"/>
<constraint firstAttribute="trailing" secondItem="obE-hs-XLa" secondAttribute="trailing" id="kZv-6I-6fD"/>
<constraint firstItem="kJv-DR-NlY" firstAttribute="height" secondItem="wWK-ob-W4A" secondAttribute="height" id="kvY-3q-eeM"/>
<constraint firstItem="wWK-ob-W4A" firstAttribute="trailing" secondItem="obE-hs-XLa" secondAttribute="trailing" id="mfr-E7-8po"/>
<constraint firstAttribute="height" constant="440" id="miA-vX-6Hr"/>
<constraint firstItem="92q-n9-Zwf" firstAttribute="height" secondItem="VUP-wm-Ah2" secondAttribute="height" id="oBc-gA-ADs"/>
<constraint firstItem="uex-bO-uvg" firstAttribute="trailing" secondItem="92q-n9-Zwf" secondAttribute="trailing" id="r2c-JO-oNO"/>
<constraint firstItem="kBC-oD-k6h" firstAttribute="leading" secondItem="uex-bO-uvg" secondAttribute="leading" id="r9g-v8-5U7"/>
<constraint firstItem="obE-hs-XLa" firstAttribute="top" secondItem="AMD-xf-cz2" secondAttribute="top" constant="20" id="s2U-ND-yc4"/>
<constraint firstItem="jKt-h1-BC7" firstAttribute="height" secondItem="Z20-6k-hhA" secondAttribute="height" id="sWH-6u-m28"/>
<constraint firstItem="kJv-DR-NlY" firstAttribute="trailing" secondItem="wWK-ob-W4A" secondAttribute="trailing" id="t41-Zi-afs"/>
<constraint firstItem="Qrr-87-KzM" firstAttribute="trailing" secondItem="gde-hr-2Sy" secondAttribute="trailing" id="vZF-Ly-XEP"/>
<constraint firstItem="Z20-6k-hhA" firstAttribute="trailing" secondItem="kJv-DR-NlY" secondAttribute="trailing" id="w7j-cD-oSq"/>
<constraint firstItem="uex-bO-uvg" firstAttribute="leading" secondItem="92q-n9-Zwf" secondAttribute="leading" id="yDZ-7l-FMk"/>
</constraints>
</scrollView>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="AMD-xf-cz2" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="4Ve-nD-CyY"/>
<constraint firstItem="obE-hs-XLa" firstAttribute="width" secondItem="8bC-Xf-vdC" secondAttribute="width" id="BAt-Qs-VNJ"/>
<constraint firstItem="AMD-xf-cz2" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="O7i-qy-sG8"/>
<constraint firstItem="AMD-xf-cz2" firstAttribute="width" secondItem="8bC-Xf-vdC" secondAttribute="width" id="Oqp-06-c4N"/>
<constraint firstAttribute="trailing" secondItem="AMD-xf-cz2" secondAttribute="trailing" id="eJF-uE-CjV"/>
</constraints>
</view> </view>
<connections> <connections>
<outlet property="allowCropSwitch" destination="0ju-HJ-A06" id="PHl-Yf-uf2"/> <outlet property="allowCropSwitch" destination="0ju-HJ-A06" id="PHl-Yf-uf2"/>
<outlet property="allowPickingGifSwitch" destination="zLj-vc-Xwz" id="1UG-vY-alU"/> <outlet property="allowPickingGifSwitch" destination="zLj-vc-Xwz" id="1UG-vY-alU"/>
<outlet property="allowPickingImageSwitch" destination="iRQ-aE-1KG" id="V7a-u6-cLv"/> <outlet property="allowPickingImageSwitch" destination="iRQ-aE-1KG" id="V7a-u6-cLv"/>
<outlet property="allowPickingMuitlpleVideoSwitch" destination="edM-ah-5KZ" id="VUN-EN-OaU"/>
<outlet property="allowPickingOriginalPhotoSwitch" destination="4L3-Da-pcd" id="KFm-Zl-dpD"/> <outlet property="allowPickingOriginalPhotoSwitch" destination="4L3-Da-pcd" id="KFm-Zl-dpD"/>
<outlet property="allowPickingVideoSwitch" destination="a58-aK-ZB0" id="9Ti-hW-QRj"/> <outlet property="allowPickingVideoSwitch" destination="a58-aK-ZB0" id="9Ti-hW-QRj"/>
<outlet property="columnNumberTF" destination="YR1-nJ-q0v" id="TE2-iH-EWE"/> <outlet property="columnNumberTF" destination="YR1-nJ-q0v" id="TE2-iH-EWE"/>
<outlet property="maxCountTF" destination="37K-cO-hgf" id="776-gE-tea"/> <outlet property="maxCountTF" destination="37K-cO-hgf" id="776-gE-tea"/>
<outlet property="needCircleCropSwitch" destination="hsH-wt-l1R" id="SVP-EE-wgf"/> <outlet property="needCircleCropSwitch" destination="hsH-wt-l1R" id="SVP-EE-wgf"/>
<outlet property="scrollView" destination="AMD-xf-cz2" id="0Bb-Te-K4h"/>
<outlet property="showSheetSwitch" destination="uHt-bT-lBZ" id="NxK-wM-ivE"/> <outlet property="showSheetSwitch" destination="uHt-bT-lBZ" id="NxK-wM-ivE"/>
<outlet property="showTakePhotoBtnSwitch" destination="jpa-B9-8n6" id="lh8-2O-IWS"/> <outlet property="showTakePhotoBtnSwitch" destination="jpa-B9-8n6" id="lh8-2O-IWS"/>
<outlet property="sortAscendingSwitch" destination="Rbt-bh-r0x" id="WEA-Vq-uSg"/> <outlet property="sortAscendingSwitch" destination="Rbt-bh-r0x" id="WEA-Vq-uSg"/>
...@@ -273,7 +343,7 @@ ...@@ -273,7 +343,7 @@
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="368" y="318"/> <point key="canvasLocation" x="367.19999999999999" y="317.99100449775113"/>
</scene> </scene>
</scenes> </scenes>
</document> </document>
...@@ -25,6 +25,7 @@ typedef enum : NSUInteger { ...@@ -25,6 +25,7 @@ typedef enum : NSUInteger {
@property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL); @property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL);
@property (nonatomic, assign) TZAssetCellType type; @property (nonatomic, assign) TZAssetCellType type;
@property (nonatomic, assign) BOOL allowPickingGif; @property (nonatomic, assign) BOOL allowPickingGif;
@property (nonatomic, assign) BOOL allowPickingMultipleVideo;
@property (nonatomic, copy) NSString *representedAssetIdentifier; @property (nonatomic, copy) NSString *representedAssetIdentifier;
@property (nonatomic, assign) int32_t imageRequestID; @property (nonatomic, assign) int32_t imageRequestID;
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
if (model.isSelected) { if (model.isSelected) {
[self fetchBigImage]; [self fetchBigImage];
} }
[self setNeedsLayout];
} }
- (void)setShowSelectBtn:(BOOL)showSelectBtn { - (void)setShowSelectBtn:(BOOL)showSelectBtn {
...@@ -83,25 +84,27 @@ ...@@ -83,25 +84,27 @@
- (void)setType:(TZAssetCellType)type { - (void)setType:(TZAssetCellType)type {
_type = type; _type = type;
if (type == TZAssetCellTypePhoto || type == TZAssetCellTypeLivePhoto || (type == TZAssetCellTypePhotoGif && !self.allowPickingGif)) { if (type == TZAssetCellTypePhoto || type == TZAssetCellTypeLivePhoto || (type == TZAssetCellTypePhotoGif && !self.allowPickingGif) || self.allowPickingMultipleVideo) {
_selectImageView.hidden = NO; _selectImageView.hidden = NO;
_selectPhotoButton.hidden = NO; _selectPhotoButton.hidden = NO;
_bottomView.hidden = YES; _bottomView.hidden = YES;
} else { // Video of Gif } else { // Video of Gif
_selectImageView.hidden = YES; _selectImageView.hidden = YES;
_selectPhotoButton.hidden = YES; _selectPhotoButton.hidden = YES;
_bottomView.hidden = NO; }
if (type == TZAssetCellTypeVideo) {
self.timeLength.text = _model.timeLength; if (type == TZAssetCellTypeVideo) {
self.videoImgView.hidden = NO; self.bottomView.hidden = NO;
_timeLength.tz_left = self.videoImgView.tz_right; self.timeLength.text = _model.timeLength;
_timeLength.textAlignment = NSTextAlignmentRight; self.videoImgView.hidden = NO;
} else { _timeLength.tz_left = self.videoImgView.tz_right;
self.timeLength.text = @"GIF"; _timeLength.textAlignment = NSTextAlignmentRight;
self.videoImgView.hidden = YES; } else if (type == TZAssetCellTypePhotoGif) {
_timeLength.tz_left = 5; self.bottomView.hidden = NO;
_timeLength.textAlignment = NSTextAlignmentLeft; self.timeLength.text = @"GIF";
} self.videoImgView.hidden = YES;
_timeLength.tz_left = 5;
_timeLength.textAlignment = NSTextAlignmentLeft;
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#import <Photos/Photos.h> #import <Photos/Photos.h>
#import "TZAssetModel.h"
@class TZAlbumModel,TZAssetModel; @class TZAlbumModel,TZAssetModel;
@protocol TZImagePickerControllerDelegate; @protocol TZImagePickerControllerDelegate;
...@@ -98,6 +99,9 @@ ...@@ -98,6 +99,9 @@
/// 修正图片转向 /// 修正图片转向
- (UIImage *)fixOrientation:(UIImage *)aImage; - (UIImage *)fixOrientation:(UIImage *)aImage;
/// 获取asset的资源类型
- (TZAssetModelMediaType)getAssetType:(id)asset;
@end @end
//@interface TZSortDescriptor : NSSortDescriptor //@interface TZSortDescriptor : NSSortDescriptor
......
...@@ -315,24 +315,13 @@ static dispatch_once_t onceToken; ...@@ -315,24 +315,13 @@ static dispatch_once_t onceToken;
if (!canSelect) return nil; if (!canSelect) return nil;
TZAssetModel *model; TZAssetModel *model;
TZAssetModelMediaType type = TZAssetModelMediaTypePhoto; TZAssetModelMediaType type = [self getAssetType:asset];
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = (PHAsset *)asset;
if (phAsset.mediaType == PHAssetMediaTypeVideo) type = TZAssetModelMediaTypeVideo;
else if (phAsset.mediaType == PHAssetMediaTypeAudio) type = TZAssetModelMediaTypeAudio;
else if (phAsset.mediaType == PHAssetMediaTypeImage) {
if (iOS9_1Later) {
// if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) type = TZAssetModelMediaTypeLivePhoto;
}
// Gif
if ([[phAsset valueForKey:@"filename"] hasSuffix:@"GIF"]) {
type = TZAssetModelMediaTypePhotoGif;
}
}
if (!allowPickingVideo && type == TZAssetModelMediaTypeVideo) return nil; if (!allowPickingVideo && type == TZAssetModelMediaTypeVideo) return nil;
if (!allowPickingImage && type == TZAssetModelMediaTypePhoto) return nil; if (!allowPickingImage && type == TZAssetModelMediaTypePhoto) return nil;
if (!allowPickingImage && type == TZAssetModelMediaTypePhotoGif) return nil; if (!allowPickingImage && type == TZAssetModelMediaTypePhotoGif) return nil;
PHAsset *phAsset = (PHAsset *)asset;
if (self.hideWhenCanNotSelect) { if (self.hideWhenCanNotSelect) {
// 过滤掉尺寸不满足要求的图片 // 过滤掉尺寸不满足要求的图片
if (![self isPhotoSelectableWithAsset:phAsset]) { if (![self isPhotoSelectableWithAsset:phAsset]) {
...@@ -348,8 +337,7 @@ static dispatch_once_t onceToken; ...@@ -348,8 +337,7 @@ static dispatch_once_t onceToken;
return model; return model;
} }
/// Allow picking video /// Allow picking video
if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { if (type == TZAssetModelMediaTypeVideo) {
type = TZAssetModelMediaTypeVideo;
NSTimeInterval duration = [[asset valueForProperty:ALAssetPropertyDuration] doubleValue]; NSTimeInterval duration = [[asset valueForProperty:ALAssetPropertyDuration] doubleValue];
NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration]; NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration];
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
...@@ -367,6 +355,29 @@ static dispatch_once_t onceToken; ...@@ -367,6 +355,29 @@ static dispatch_once_t onceToken;
return model; return model;
} }
- (TZAssetModelMediaType)getAssetType:(id)asset {
TZAssetModelMediaType type = TZAssetModelMediaTypePhoto;
if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = (PHAsset *)asset;
if (phAsset.mediaType == PHAssetMediaTypeVideo) type = TZAssetModelMediaTypeVideo;
else if (phAsset.mediaType == PHAssetMediaTypeAudio) type = TZAssetModelMediaTypeAudio;
else if (phAsset.mediaType == PHAssetMediaTypeImage) {
if (iOS9_1Later) {
// if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) type = TZAssetModelMediaTypeLivePhoto;
}
// Gif
if ([[phAsset valueForKey:@"filename"] hasSuffix:@"GIF"]) {
type = TZAssetModelMediaTypePhotoGif;
}
}
} else {
if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
type = TZAssetModelMediaTypeVideo;
}
}
return type;
}
- (NSString *)getNewTimeFromDurationSecond:(NSInteger)duration { - (NSString *)getNewTimeFromDurationSecond:(NSInteger)duration {
NSString *newTime; NSString *newTime;
if (duration < 10) { if (duration < 10) {
......
...@@ -71,6 +71,8 @@ ...@@ -71,6 +71,8 @@
/// Default is YES, if set NO, user can't picking video. /// Default is YES, if set NO, user can't picking video.
/// 默认为YES,如果设置为NO,用户将不能选择视频 /// 默认为YES,如果设置为NO,用户将不能选择视频
@property (nonatomic, assign) BOOL allowPickingVideo; @property (nonatomic, assign) BOOL allowPickingVideo;
/// Default is NO / 默认为NO,为YES时可以多选视频/gif图片,和照片共享最大可选张数maxImagesCount的限制
@property (nonatomic, assign) BOOL allowPickingMultipleVideo;
/// Default is NO, if set YES, user can picking gif image. /// Default is NO, if set YES, user can picking gif image.
/// 默认为NO,如果设置为YES,用户可以选择gif图片 /// 默认为NO,如果设置为YES,用户可以选择gif图片
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
self.navigationBar.barTintColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:1.0]; self.navigationBar.barTintColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:1.0];
self.navigationBar.tintColor = [UIColor whiteColor]; self.navigationBar.tintColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
if (!TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
} }
} }
...@@ -449,7 +450,7 @@ ...@@ -449,7 +450,7 @@
_selectedAssets = selectedAssets; _selectedAssets = selectedAssets;
_selectedModels = [NSMutableArray array]; _selectedModels = [NSMutableArray array];
for (id asset in selectedAssets) { for (id asset in selectedAssets) {
TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypePhoto]; TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:[[TZImageManager manager] getAssetType:asset]];
model.isSelected = YES; model.isSelected = YES;
[_selectedModels addObject:model]; [_selectedModels addObject:model];
} }
......
...@@ -431,6 +431,7 @@ static CGFloat itemMargin = 5; ...@@ -431,6 +431,7 @@ static CGFloat itemMargin = 5;
} }
// the cell dipaly photo or video / 展示照片或视频的cell // the cell dipaly photo or video / 展示照片或视频的cell
TZAssetCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCell" forIndexPath:indexPath]; TZAssetCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCell" forIndexPath:indexPath];
cell.allowPickingMultipleVideo = tzImagePickerVc.allowPickingMultipleVideo;
cell.photoDefImageName = tzImagePickerVc.photoDefImageName; cell.photoDefImageName = tzImagePickerVc.photoDefImageName;
cell.photoSelImageName = tzImagePickerVc.photoSelImageName; cell.photoSelImageName = tzImagePickerVc.photoSelImageName;
TZAssetModel *model; TZAssetModel *model;
...@@ -492,7 +493,7 @@ static CGFloat itemMargin = 5; ...@@ -492,7 +493,7 @@ static CGFloat itemMargin = 5;
index = indexPath.row - 1; index = indexPath.row - 1;
} }
TZAssetModel *model = _models[index]; TZAssetModel *model = _models[index];
if (model.type == TZAssetModelMediaTypeVideo) { if (model.type == TZAssetModelMediaTypeVideo && !tzImagePickerVc.allowPickingMultipleVideo) {
if (tzImagePickerVc.selectedModels.count > 0) { if (tzImagePickerVc.selectedModels.count > 0) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Can not choose both video and photo"]]; [imagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Can not choose both video and photo"]];
...@@ -501,7 +502,7 @@ static CGFloat itemMargin = 5; ...@@ -501,7 +502,7 @@ static CGFloat itemMargin = 5;
videoPlayerVc.model = model; videoPlayerVc.model = model;
[self.navigationController pushViewController:videoPlayerVc animated:YES]; [self.navigationController pushViewController:videoPlayerVc animated:YES];
} }
} else if (model.type == TZAssetModelMediaTypePhotoGif && tzImagePickerVc.allowPickingGif) { } else if (model.type == TZAssetModelMediaTypePhotoGif && tzImagePickerVc.allowPickingGif && !tzImagePickerVc.allowPickingMultipleVideo) {
if (tzImagePickerVc.selectedModels.count > 0) { if (tzImagePickerVc.selectedModels.count > 0) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Can not choose both photo and GIF"]]; [imagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Can not choose both photo and GIF"]];
...@@ -633,16 +634,21 @@ static CGFloat itemMargin = 5; ...@@ -633,16 +634,21 @@ static CGFloat itemMargin = 5;
- (void)scrollCollectionViewToBottom { - (void)scrollCollectionViewToBottom {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_shouldScrollToBottom && _models.count > 0 && tzImagePickerVc.sortAscendingByModificationDate) { if (_shouldScrollToBottom && _models.count > 0) {
NSInteger item = _models.count - 1; NSInteger item = 0;
if (_showTakePhotoBtn) { if (tzImagePickerVc.sortAscendingByModificationDate) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; item = _models.count - 1;
if (tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowTakePicture) { if (_showTakePhotoBtn) {
item += 1; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowTakePicture) {
item += 1;
}
} }
} }
[_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:NO]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
_shouldScrollToBottom = NO; [_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:NO];
_shouldScrollToBottom = NO;
});
} }
} }
...@@ -720,7 +726,7 @@ static CGFloat itemMargin = 5; ...@@ -720,7 +726,7 @@ static CGFloat itemMargin = 5;
TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init]; TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init];
if (tzImagePickerVc.sortAscendingByModificationDate) { if (tzImagePickerVc.sortAscendingByModificationDate) {
photoPreviewVc.currentIndex = _models.count - 1; photoPreviewVc.currentIndex = _models.count - 1;
}else{ } else {
photoPreviewVc.currentIndex = 0; photoPreviewVc.currentIndex = 0;
} }
photoPreviewVc.models = _models; photoPreviewVc.models = _models;
...@@ -870,7 +876,7 @@ static CGFloat itemMargin = 5; ...@@ -870,7 +876,7 @@ static CGFloat itemMargin = 5;
@implementation TZCollectionView @implementation TZCollectionView
- (BOOL)touchesShouldCancelInContentView:(UIView *)view { - (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ( [view isKindOfClass:[UIControl class]]) { if ([view isKindOfClass:[UIControl class]]) {
return YES; return YES;
} }
return [super touchesShouldCancelInContentView:view]; return [super touchesShouldCancelInContentView:view];
......
...@@ -8,11 +8,18 @@ ...@@ -8,11 +8,18 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class TZAssetModel,TZProgressView,TZPhotoPreviewView; @class TZAssetModel;
@interface TZPhotoPreviewCell : UICollectionViewCell @interface TZAssetPreviewCell : UICollectionViewCell
@property (nonatomic, strong) TZAssetModel *model; @property (nonatomic, strong) TZAssetModel *model;
@property (nonatomic, copy) void (^singleTapGestureBlock)(); @property (nonatomic, copy) void (^singleTapGestureBlock)();
- (void)configSubviews;
- (void)photoPreviewCollectionViewDidScroll;
@end
@class TZAssetModel,TZProgressView,TZPhotoPreviewView;
@interface TZPhotoPreviewCell : TZAssetPreviewCell
@property (nonatomic, copy) void (^imageProgressUpdateBlock)(double progress); @property (nonatomic, copy) void (^imageProgressUpdateBlock)(double progress);
@property (nonatomic, strong) TZPhotoPreviewView *previewView; @property (nonatomic, strong) TZPhotoPreviewView *previewView;
...@@ -43,3 +50,18 @@ ...@@ -43,3 +50,18 @@
- (void)recoverSubviews; - (void)recoverSubviews;
@end @end
@class AVPlayer, AVPlayerLayer;
@interface TZVideoPreviewCell : TZAssetPreviewCell
@property (strong, nonatomic) AVPlayer *player;
@property (strong, nonatomic) AVPlayerLayer *playerLayer;
@property (strong, nonatomic) UIButton *playButton;
@property (strong, nonatomic) UIImage *cover;
- (void)pausePlayerAndShowNaviBar;
@end
@interface TZGifPreviewCell : TZAssetPreviewCell
@property (strong, nonatomic) TZPhotoPreviewView *previewView;
@end
...@@ -12,35 +12,58 @@ ...@@ -12,35 +12,58 @@
#import "TZImageManager.h" #import "TZImageManager.h"
#import "TZProgressView.h" #import "TZProgressView.h"
#import "TZImageCropManager.h" #import "TZImageCropManager.h"
#import <MediaPlayer/MediaPlayer.h>
#import "TZImagePickerController.h"
@interface TZPhotoPreviewCell () @implementation TZAssetPreviewCell
@end
@implementation TZPhotoPreviewCell
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.backgroundColor = [UIColor blackColor]; self.backgroundColor = [UIColor blackColor];
self.previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero]; [self configSubviews];
__weak typeof(self) weakSelf = self; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(photoPreviewCollectionViewDidScroll) name:@"photoPreviewCollectionViewDidScroll" object:nil];
[self.previewView setSingleTapGestureBlock:^{
if (weakSelf.singleTapGestureBlock) {
weakSelf.singleTapGestureBlock();
}
}];
[self.previewView setImageProgressUpdateBlock:^(double progress) {
if (weakSelf.imageProgressUpdateBlock) {
weakSelf.imageProgressUpdateBlock(progress);
}
}];
[self addSubview:self.previewView];
} }
return self; return self;
} }
- (void)configSubviews {
}
#pragma mark - Notification
- (void)photoPreviewCollectionViewDidScroll {
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
@implementation TZPhotoPreviewCell
- (void)configSubviews {
self.previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
__weak typeof(self) weakSelf = self;
[self.previewView setSingleTapGestureBlock:^{
if (weakSelf.singleTapGestureBlock) {
weakSelf.singleTapGestureBlock();
}
}];
[self.previewView setImageProgressUpdateBlock:^(double progress) {
if (weakSelf.imageProgressUpdateBlock) {
weakSelf.imageProgressUpdateBlock(progress);
}
}];
[self addSubview:self.previewView];
}
- (void)setModel:(TZAssetModel *)model { - (void)setModel:(TZAssetModel *)model {
_model = model; [super setModel:model];
_previewView.asset = model.asset; _previewView.asset = model.asset;
} }
...@@ -297,3 +320,128 @@ ...@@ -297,3 +320,128 @@
} }
@end @end
@implementation TZVideoPreviewCell
- (void)configSubviews {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:UIApplicationWillResignActiveNotification object:nil];
}
- (void)configPlayButton {
if (_playButton) {
[_playButton removeFromSuperview];
}
_playButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay.png"] forState:UIControlStateNormal];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlayHL.png"] forState:UIControlStateHighlighted];
[_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_playButton];
}
- (void)setModel:(TZAssetModel *)model {
[super setModel:model];
[self configMoviePlayer];
}
- (void)configMoviePlayer {
if (_player) {
[_playerLayer removeFromSuperlayer];
_playerLayer = nil;
[_player pause];
_player = nil;
}
[[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
_cover = photo;
}];
[[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
_player = [AVPlayer playerWithPlayerItem:playerItem];
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
_playerLayer.backgroundColor = [UIColor blackColor].CGColor;
_playerLayer.frame = self.bounds;
[self.layer addSublayer:_playerLayer];
[self configPlayButton];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:_player.currentItem];
});
}];
}
- (void)layoutSubviews {
[super layoutSubviews];
_playerLayer.frame = self.bounds;
_playButton.frame = CGRectMake(0, 64, self.tz_width, self.tz_height - 64 - 44);
}
- (void)photoPreviewCollectionViewDidScroll {
[self pausePlayerAndShowNaviBar];
}
#pragma mark - Click Event
- (void)playButtonClick {
CMTime currentTime = _player.currentItem.currentTime;
CMTime durationTime = _player.currentItem.duration;
if (_player.rate == 0.0f) {
if (currentTime.value == durationTime.value) [_player.currentItem seekToTime:CMTimeMake(0, 1)];
[_player play];
[_playButton setImage:nil forState:UIControlStateNormal];
if (!TZ_isGlobalHideStatusBar && iOS7Later) {
[UIApplication sharedApplication].statusBarHidden = YES;
}
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
} else {
[self pausePlayerAndShowNaviBar];
}
}
- (void)pausePlayerAndShowNaviBar {
if (_player.rate != 0.0) {
[_player pause];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay.png"] forState:UIControlStateNormal];
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
}
}
@end
@implementation TZGifPreviewCell
- (void)configSubviews {
[self configPreviewView];
}
- (void)configPreviewView {
_previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
__weak typeof(self) weakSelf = self;
[_previewView setSingleTapGestureBlock:^{
[weakSelf signleTapAction];
}];
[self addSubview:_previewView];
}
- (void)setModel:(TZAssetModel *)model {
[super setModel:model];
_previewView.model = self.model;
}
- (void)layoutSubviews {
[super layoutSubviews];
_previewView.frame = self.bounds;
}
#pragma mark - Click Event
- (void)signleTapAction {
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
}
@end
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
- (void)configCustomNaviBar { - (void)configCustomNaviBar {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_naviBar = [[UIView alloc] initWithFrame:CGRectZero]; _naviBar = [[UIView alloc] initWithFrame:CGRectZero];
_naviBar.backgroundColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:0.7]; _naviBar.backgroundColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:0.7];
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
_numberLabel.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count]; _numberLabel.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
_numberLabel.hidden = _tzImagePickerVc.selectedModels.count <= 0; _numberLabel.hidden = _tzImagePickerVc.selectedModels.count <= 0;
_numberLabel.backgroundColor = [UIColor clearColor]; _numberLabel.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addSubview:_originalPhotoLabel]; [_originalPhotoButton addSubview:_originalPhotoLabel];
[_toolBar addSubview:_doneButton]; [_toolBar addSubview:_doneButton];
[_toolBar addSubview:_originalPhotoButton]; [_toolBar addSubview:_originalPhotoButton];
...@@ -177,6 +177,8 @@ ...@@ -177,6 +177,8 @@
_collectionView.contentSize = CGSizeMake(self.models.count * (self.view.tz_width + 20), 0); _collectionView.contentSize = CGSizeMake(self.models.count * (self.view.tz_width + 20), 0);
[self.view addSubview:_collectionView]; [self.view addSubview:_collectionView];
[_collectionView registerClass:[TZPhotoPreviewCell class] forCellWithReuseIdentifier:@"TZPhotoPreviewCell"]; [_collectionView registerClass:[TZPhotoPreviewCell class] forCellWithReuseIdentifier:@"TZPhotoPreviewCell"];
[_collectionView registerClass:[TZVideoPreviewCell class] forCellWithReuseIdentifier:@"TZVideoPreviewCell"];
[_collectionView registerClass:[TZGifPreviewCell class] forCellWithReuseIdentifier:@"TZGifPreviewCell"];
} }
- (void)configCropView { - (void)configCropView {
...@@ -213,6 +215,7 @@ ...@@ -213,6 +215,7 @@
- (void)viewDidLayoutSubviews { - (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, 64); _naviBar.frame = CGRectMake(0, 0, self.view.tz_width, 64);
_backButton.frame = CGRectMake(10, 10, 44, 44); _backButton.frame = CGRectMake(10, 10, 44, 44);
...@@ -227,10 +230,11 @@ ...@@ -227,10 +230,11 @@
CGFloat offsetX = _offsetItemCount * _layout.itemSize.width; CGFloat offsetX = _offsetItemCount * _layout.itemSize.width;
[_collectionView setContentOffset:CGPointMake(offsetX, 0)]; [_collectionView setContentOffset:CGPointMake(offsetX, 0)];
} }
[_collectionView reloadData]; if (_tzImagePickerVc.allowCrop) {
[_collectionView reloadData];
}
_toolBar.frame = CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44); _toolBar.frame = CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44);
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_tzImagePickerVc.allowPickingOriginalPhoto) { if (_tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width; CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
_originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44); _originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44);
...@@ -260,14 +264,14 @@ ...@@ -260,14 +264,14 @@
NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a maximum of %zd photos"], _tzImagePickerVc.maxImagesCount]; NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a maximum of %zd photos"], _tzImagePickerVc.maxImagesCount];
[_tzImagePickerVc showAlertWithTitle:title]; [_tzImagePickerVc showAlertWithTitle:title];
return; return;
// 2. if not over the maxImagesCount / 如果没有超过最大个数限制 // 2. if not over the maxImagesCount / 如果没有超过最大个数限制
} else { } else {
[_tzImagePickerVc.selectedModels addObject:model]; [_tzImagePickerVc.selectedModels addObject:model];
if (self.photos) { if (self.photos) {
[_tzImagePickerVc.selectedAssets addObject:_assetsTemp[_currentIndex]]; [_tzImagePickerVc.selectedAssets addObject:_assetsTemp[_currentIndex]];
[self.photos addObject:_photosTemp[_currentIndex]]; [self.photos addObject:_photosTemp[_currentIndex]];
} }
if (model.type == TZAssetModelMediaTypeVideo) { if (model.type == TZAssetModelMediaTypeVideo && !_tzImagePickerVc.allowPickingMultipleVideo) {
[_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Select the video when in multi state, we will handle the video as a photo"]]; [_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Select the video when in multi state, we will handle the video as a photo"]];
} }
} }
...@@ -328,7 +332,7 @@ ...@@ -328,7 +332,7 @@
_alertView = [_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Synchronizing photos from iCloud"]]; _alertView = [_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Synchronizing photos from iCloud"]];
return; return;
} }
// 如果没有选中过照片 点击确定时选中当前预览的照片 // 如果没有选中过照片 点击确定时选中当前预览的照片
if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0) { if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0) {
TZAssetModel *model = _models[_currentIndex]; TZAssetModel *model = _models[_currentIndex];
...@@ -369,6 +373,12 @@ ...@@ -369,6 +373,12 @@
} }
} }
- (void)didTapPreviewCell {
self.isHideNaviBar = !self.isHideNaviBar;
_naviBar.hidden = self.isHideNaviBar;
_toolBar.hidden = self.isHideNaviBar;
}
#pragma mark - UIScrollViewDelegate #pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
...@@ -381,6 +391,8 @@ ...@@ -381,6 +391,8 @@
_currentIndex = currentIndex; _currentIndex = currentIndex;
[self refreshNaviBarAndBottomBarState]; [self refreshNaviBarAndBottomBarState];
} }
[[NSNotificationCenter defaultCenter] postNotificationName:@"photoPreviewCollectionViewDidScroll" object:nil];
} }
#pragma mark - UICollectionViewDataSource && Delegate #pragma mark - UICollectionViewDataSource && Delegate
...@@ -390,34 +402,38 @@ ...@@ -390,34 +402,38 @@
} }
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TZPhotoPreviewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZPhotoPreviewCell" forIndexPath:indexPath];
cell.model = _models[indexPath.row];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
cell.cropRect = _tzImagePickerVc.cropRect; TZAssetModel *model = _models[indexPath.row];
cell.allowCrop = _tzImagePickerVc.allowCrop;
TZAssetPreviewCell *cell;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
if (!cell.singleTapGestureBlock) { if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypeVideo) {
__weak typeof(_naviBar) weakNaviBar = _naviBar; cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZVideoPreviewCell" forIndexPath:indexPath];
__weak typeof(_toolBar) weakToolBar = _toolBar; } else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) {
cell.singleTapGestureBlock = ^(){ cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZGifPreviewCell" forIndexPath:indexPath];
// show or hide naviBar / 显示或隐藏导航栏 } else {
weakSelf.isHideNaviBar = !weakSelf.isHideNaviBar; cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZPhotoPreviewCell" forIndexPath:indexPath];
weakNaviBar.hidden = weakSelf.isHideNaviBar; TZPhotoPreviewCell *photoPreviewCell = (TZPhotoPreviewCell *)cell;
weakToolBar.hidden = weakSelf.isHideNaviBar; photoPreviewCell.cropRect = _tzImagePickerVc.cropRect;
}; photoPreviewCell.allowCrop = _tzImagePickerVc.allowCrop;
} __weak typeof(_tzImagePickerVc) weakTzImagePickerVc = _tzImagePickerVc;
__weak typeof(_tzImagePickerVc) weakTzImagePickerVc = _tzImagePickerVc; __weak typeof(_collectionView) weakCollectionView = _collectionView;
__weak typeof(_collectionView) weakCollectionView = _collectionView; __weak typeof(photoPreviewCell) weakCell = photoPreviewCell;
__weak typeof(cell) weakCell = cell; [photoPreviewCell setImageProgressUpdateBlock:^(double progress) {
[cell setImageProgressUpdateBlock:^(double progress) { weakSelf.progress = progress;
weakSelf.progress = progress; if (progress >= 1) {
if (progress >= 1) { if (weakSelf.alertView && [weakCollectionView.visibleCells containsObject:weakCell]) {
if (weakSelf.alertView && [weakCollectionView.visibleCells containsObject:weakCell]) { [weakTzImagePickerVc hideAlertView:weakSelf.alertView];
[weakTzImagePickerVc hideAlertView:weakSelf.alertView]; weakSelf.alertView = nil;
weakSelf.alertView = nil; [weakSelf doneButtonClick];
[weakSelf doneButtonClick]; }
} }
} }];
}
cell.model = model;
[cell setSingleTapGestureBlock:^{
[weakSelf didTapPreviewCell];
}]; }];
return cell; return cell;
} }
...@@ -431,6 +447,8 @@ ...@@ -431,6 +447,8 @@
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) { if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) {
[(TZPhotoPreviewCell *)cell recoverSubviews]; [(TZPhotoPreviewCell *)cell recoverSubviews];
} else if ([cell isKindOfClass:[TZVideoPreviewCell class]]) {
[(TZVideoPreviewCell *)cell pausePlayerAndShowNaviBar];
} }
} }
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
self.navigationItem.title = tzImagePickerVc.previewBtnTitleStr; self.navigationItem.title = tzImagePickerVc.previewBtnTitleStr;
} }
[self configMoviePlayer]; [self configMoviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:UIApplicationWillResignActiveNotification object:nil];
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
_deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_deleteBtn setImage:[UIImage imageNamed:@"photo_delete"] forState:UIControlStateNormal]; [_deleteBtn setImage:[UIImage imageNamed:@"photo_delete"] forState:UIControlStateNormal];
_deleteBtn.frame = CGRectMake(self.tz_width - 36, 0, 36, 36);
_deleteBtn.imageEdgeInsets = UIEdgeInsetsMake(-10, 0, 0, -10); _deleteBtn.imageEdgeInsets = UIEdgeInsetsMake(-10, 0, 0, -10);
_deleteBtn.alpha = 0.6; _deleteBtn.alpha = 0.6;
[self addSubview:_deleteBtn]; [self addSubview:_deleteBtn];
...@@ -43,7 +42,6 @@ ...@@ -43,7 +42,6 @@
_gifLable.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8]; _gifLable.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
_gifLable.textAlignment = NSTextAlignmentCenter; _gifLable.textAlignment = NSTextAlignmentCenter;
_gifLable.font = [UIFont systemFontOfSize:10]; _gifLable.font = [UIFont systemFontOfSize:10];
_gifLable.frame = CGRectMake(self.tz_width - 25, self.tz_height - 14, 25, 14);
[self addSubview:_gifLable]; [self addSubview:_gifLable];
} }
return self; return self;
...@@ -52,6 +50,8 @@ ...@@ -52,6 +50,8 @@
- (void)layoutSubviews { - (void)layoutSubviews {
[super layoutSubviews]; [super layoutSubviews];
_imageView.frame = self.bounds; _imageView.frame = self.bounds;
_gifLable.frame = CGRectMake(self.tz_width - 25, self.tz_height - 14, 25, 14);
_deleteBtn.frame = CGRectMake(self.tz_width - 36, 0, 36, 36);
CGFloat width = self.tz_width / 3.0; CGFloat width = self.tz_width / 3.0;
_videoImageView.frame = CGRectMake(width, width, width, width); _videoImageView.frame = CGRectMake(width, width, width, width);
} }
......
...@@ -29,8 +29,11 @@ ...@@ -29,8 +29,11 @@
} }
@property (nonatomic, strong) UIImagePickerController *imagePickerVc; @property (nonatomic, strong) UIImagePickerController *imagePickerVc;
@property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) UICollectionView *collectionView;
@property (strong, nonatomic) LxGridViewFlowLayout *layout;
@property (strong, nonatomic) CLLocation *location; @property (strong, nonatomic) CLLocation *location;
// 6个设置开关
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
// 设置开关
@property (weak, nonatomic) IBOutlet UISwitch *showTakePhotoBtnSwitch; ///< 在内部显示拍照按钮 @property (weak, nonatomic) IBOutlet UISwitch *showTakePhotoBtnSwitch; ///< 在内部显示拍照按钮
@property (weak, nonatomic) IBOutlet UISwitch *sortAscendingSwitch; ///< 照片排列按修改时间升序 @property (weak, nonatomic) IBOutlet UISwitch *sortAscendingSwitch; ///< 照片排列按修改时间升序
@property (weak, nonatomic) IBOutlet UISwitch *allowPickingVideoSwitch; ///< 允许选择视频 @property (weak, nonatomic) IBOutlet UISwitch *allowPickingVideoSwitch; ///< 允许选择视频
...@@ -42,6 +45,7 @@ ...@@ -42,6 +45,7 @@
@property (weak, nonatomic) IBOutlet UITextField *columnNumberTF; @property (weak, nonatomic) IBOutlet UITextField *columnNumberTF;
@property (weak, nonatomic) IBOutlet UISwitch *allowCropSwitch; @property (weak, nonatomic) IBOutlet UISwitch *allowCropSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *needCircleCropSwitch; @property (weak, nonatomic) IBOutlet UISwitch *needCircleCropSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *allowPickingMuitlpleVideoSwitch;
@end @end
@implementation ViewController @implementation ViewController
...@@ -83,13 +87,8 @@ ...@@ -83,13 +87,8 @@
- (void)configCollectionView { - (void)configCollectionView {
// 如不需要长按排序效果,将LxGridViewFlowLayout类改成UICollectionViewFlowLayout即可 // 如不需要长按排序效果,将LxGridViewFlowLayout类改成UICollectionViewFlowLayout即可
LxGridViewFlowLayout *layout = [[LxGridViewFlowLayout alloc] init]; _layout = [[LxGridViewFlowLayout alloc] init];
_margin = 4; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout];
_itemWH = (self.view.tz_width - 2 * _margin - 4) / 3 - _margin;
layout.itemSize = CGSizeMake(_itemWH, _itemWH);
layout.minimumInteritemSpacing = _margin;
layout.minimumLineSpacing = _margin;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 409, self.view.tz_width, self.view.tz_height - 409) collectionViewLayout:layout];
CGFloat rgb = 244 / 255.0; CGFloat rgb = 244 / 255.0;
_collectionView.alwaysBounceVertical = YES; _collectionView.alwaysBounceVertical = YES;
_collectionView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0]; _collectionView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
...@@ -101,6 +100,22 @@ ...@@ -101,6 +100,22 @@
[_collectionView registerClass:[TZTestCell class] forCellWithReuseIdentifier:@"TZTestCell"]; [_collectionView registerClass:[TZTestCell class] forCellWithReuseIdentifier:@"TZTestCell"];
} }
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
NSInteger contentSizeH = 12 * 35 + 20;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.scrollView.contentSize = CGSizeMake(0, contentSizeH + 5);
});
_margin = 4;
_itemWH = (self.view.tz_width - 2 * _margin - 4) / 3 - _margin;
_layout.itemSize = CGSizeMake(_itemWH, _itemWH);
_layout.minimumInteritemSpacing = _margin;
_layout.minimumLineSpacing = _margin;
[self.collectionView setCollectionViewLayout:_layout];
self.collectionView.frame = CGRectMake(0, contentSizeH, self.view.tz_width, self.view.tz_height - contentSizeH);
}
#pragma mark UICollectionView #pragma mark UICollectionView
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
...@@ -146,12 +161,12 @@ ...@@ -146,12 +161,12 @@
ALAsset *alAsset = asset; ALAsset *alAsset = asset;
isVideo = [[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]; isVideo = [[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo];
} }
if ([[asset valueForKey:@"filename"] containsString:@"GIF"] && self.allowPickingGifSwitch.isOn) { if ([[asset valueForKey:@"filename"] containsString:@"GIF"] && self.allowPickingGifSwitch.isOn && !self.allowPickingMuitlpleVideoSwitch.isOn) {
TZGifPhotoPreviewController *vc = [[TZGifPhotoPreviewController alloc] init]; TZGifPhotoPreviewController *vc = [[TZGifPhotoPreviewController alloc] init];
TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypePhotoGif timeLength:@""]; TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypePhotoGif timeLength:@""];
vc.model = model; vc.model = model;
[self presentViewController:vc animated:YES completion:nil]; [self presentViewController:vc animated:YES completion:nil];
} else if (isVideo) { // perview video / 预览视频 } else if (isVideo && !self.allowPickingMuitlpleVideoSwitch.isOn) { // perview video / 预览视频
TZVideoPlayerController *vc = [[TZVideoPlayerController alloc] init]; TZVideoPlayerController *vc = [[TZVideoPlayerController alloc] init];
TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypeVideo timeLength:@""]; TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypeVideo timeLength:@""];
vc.model = model; vc.model = model;
...@@ -159,7 +174,9 @@ ...@@ -159,7 +174,9 @@
} else { // preview photos / 预览照片 } else { // preview photos / 预览照片
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.row]; TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.row];
imagePickerVc.maxImagesCount = self.maxCountTF.text.integerValue; imagePickerVc.maxImagesCount = self.maxCountTF.text.integerValue;
imagePickerVc.allowPickingGif = self.allowPickingGifSwitch.isOn;
imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn; imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn;
imagePickerVc.allowPickingMultipleVideo = self.allowPickingMuitlpleVideoSwitch.isOn;
imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto; imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
_selectedPhotos = [NSMutableArray arrayWithArray:photos]; _selectedPhotos = [NSMutableArray arrayWithArray:photos];
...@@ -229,6 +246,7 @@ ...@@ -229,6 +246,7 @@
imagePickerVc.allowPickingImage = self.allowPickingImageSwitch.isOn; imagePickerVc.allowPickingImage = self.allowPickingImageSwitch.isOn;
imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn; imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn;
imagePickerVc.allowPickingGif = self.allowPickingGifSwitch.isOn; imagePickerVc.allowPickingGif = self.allowPickingGifSwitch.isOn;
imagePickerVc.allowPickingMultipleVideo = self.allowPickingMuitlpleVideoSwitch.isOn; // 是否可以多选视频
// 4. 照片排列按修改时间升序 // 4. 照片排列按修改时间升序
imagePickerVc.sortAscendingByModificationDate = self.sortAscendingSwitch.isOn; imagePickerVc.sortAscendingByModificationDate = self.sortAscendingSwitch.isOn;
...@@ -578,12 +596,17 @@ ...@@ -578,12 +596,17 @@
- (IBAction)allowPickingGifSwitchClick:(UISwitch *)sender { - (IBAction)allowPickingGifSwitchClick:(UISwitch *)sender {
if (sender.isOn) { if (sender.isOn) {
[_allowPickingImageSwitch setOn:YES animated:YES]; [_allowPickingImageSwitch setOn:YES animated:YES];
} else if (!self.allowPickingVideoSwitch.isOn) {
[self.allowPickingMuitlpleVideoSwitch setOn:NO animated:YES];
} }
} }
- (IBAction)allowPickingVideoSwitchClick:(UISwitch *)sender { - (IBAction)allowPickingVideoSwitchClick:(UISwitch *)sender {
if (!sender.isOn) { if (!sender.isOn) {
[_allowPickingImageSwitch setOn:YES animated:YES]; [_allowPickingImageSwitch setOn:YES animated:YES];
if (!self.allowPickingGifSwitch.isOn) {
[self.allowPickingMuitlpleVideoSwitch setOn:NO animated:YES];
}
} }
} }
...@@ -592,6 +615,9 @@ ...@@ -592,6 +615,9 @@
self.maxCountTF.text = @"1"; self.maxCountTF.text = @"1";
[self.allowPickingOriginalPhotoSwitch setOn:NO animated:YES]; [self.allowPickingOriginalPhotoSwitch setOn:NO animated:YES];
} else { } else {
if ([self.maxCountTF.text isEqualToString:@"1"]) {
self.maxCountTF.text = @"9";
}
[self.needCircleCropSwitch setOn:NO animated:YES]; [self.needCircleCropSwitch setOn:NO animated:YES];
} }
} }
...@@ -604,6 +630,10 @@ ...@@ -604,6 +630,10 @@
} }
} }
- (IBAction)allowPickingMultipleVideoSwitchClick:(UISwitch *)sender {
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES]; [self.view endEditing:YES];
} }
...@@ -621,14 +651,10 @@ ...@@ -621,14 +651,10 @@
ALAsset *alAsset = (ALAsset *)asset; ALAsset *alAsset = (ALAsset *)asset;
fileName = alAsset.defaultRepresentation.filename;; fileName = alAsset.defaultRepresentation.filename;;
} }
//NSLog(@"图片名字:%@",fileName); // NSLog(@"图片名字:%@",fileName);
} }
} }
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
#pragma clang diagnostic pop #pragma clang diagnostic pop
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment