Commit 81a214c3 authored by yuzheng.tz's avatar yuzheng.tz

优化对拍摄视频的配置,允许设置是否要拍摄视频和视频最大可拍摄时长

parent 9234c30e
<?xml version="1.0" encoding="UTF-8"?>
<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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
......@@ -263,14 +263,36 @@
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="v2g-6C-m1J" userLabel="View13">
<rect key="frame" x="0.0" y="440" width="375" height="35"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mMy-bi-cIJ">
<rect key="frame" x="225" y="2" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="showTakeVideoBtnSwitchClick:" destination="BYZ-38-t0r" eventType="valueChanged" id="YVa-sT-R3M"/>
</connections>
</switch>
<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="8H2-cq-aUq">
<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>
</subviews>
<constraints>
<constraint firstItem="VUP-wm-Ah2" firstAttribute="leading" secondItem="PA2-zk-4Ey" secondAttribute="leading" id="1iv-97-UAf"/>
<constraint firstItem="v2g-6C-m1J" firstAttribute="leading" secondItem="kBC-oD-k6h" secondAttribute="leading" id="1xv-oX-xWZ"/>
<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="v2g-6C-m1J" firstAttribute="top" secondItem="kBC-oD-k6h" secondAttribute="bottom" id="ErC-BJ-ezP"/>
<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"/>
......@@ -292,6 +314,7 @@
<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="v2g-6C-m1J" firstAttribute="trailing" secondItem="kBC-oD-k6h" secondAttribute="trailing" id="ez1-O3-KTh"/>
<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"/>
......@@ -312,6 +335,7 @@
<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="v2g-6C-m1J" firstAttribute="height" secondItem="kBC-oD-k6h" secondAttribute="height" id="xp8-5X-dXy"/>
<constraint firstItem="uex-bO-uvg" firstAttribute="leading" secondItem="92q-n9-Zwf" secondAttribute="leading" id="yDZ-7l-FMk"/>
</constraints>
</scrollView>
......@@ -338,6 +362,7 @@
<outlet property="scrollView" destination="AMD-xf-cz2" id="0Bb-Te-K4h"/>
<outlet property="showSheetSwitch" destination="uHt-bT-lBZ" id="NxK-wM-ivE"/>
<outlet property="showTakePhotoBtnSwitch" destination="jpa-B9-8n6" id="lh8-2O-IWS"/>
<outlet property="showTakeVideoBtnSwitch" destination="mMy-bi-cIJ" id="jER-Fp-aOr"/>
<outlet property="sortAscendingSwitch" destination="Rbt-bh-r0x" id="WEA-Vq-uSg"/>
</connections>
</viewController>
......
......@@ -348,7 +348,7 @@
_imageView = [[UIImageView alloc] init];
_imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
[self addSubview:_imageView];
[self.contentView addSubview:_imageView];
self.clipsToBounds = YES;
}
return self;
......
......@@ -84,9 +84,15 @@
@property(nonatomic, assign) BOOL allowPickingImage;
/// Default is YES, if set NO, user can't take picture.
/// 默认为YES,如果设置为NO,拍照按钮将隐藏,用户将不能选择照片
/// 默认为YES,如果设置为NO, 用户将不能拍摄照片
@property(nonatomic, assign) BOOL allowTakePicture;
/// Default is YES, if set NO, user can't take video.
/// 默认为YES,如果设置为NO, 用户将不能拍摄视频
@property(nonatomic, assign) BOOL allowTakeVideo;
/// Default value is 10 minutes / 视频最大拍摄时间,默认是10分钟,单位是秒
@property (assign, nonatomic) NSTimeInterval videoMaximumDuration;
/// 首选语言,如果设置了就用该语言,不设则取当前系统语言。
/// 由于目前只支持中文、繁体中文、英文、越南语。故该属性只支持zh-Hans、zh-Hant、en、vi四种值,其余值无效。
@property (copy, nonatomic) NSString *preferredLanguage;
......
......@@ -133,6 +133,11 @@
[super viewWillAppear:animated];
_originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
[UIApplication sharedApplication].statusBarStyle = self.statusBarStyle;
if ([self.takePictureImageName isEqualToString:@"takePicture80"]) {
if (self.allowTakePicture && !self.allowTakeVideo) {
self.takePictureImageName = @"takePicture";
}
}
}
- (void)viewWillDisappear:(BOOL)animated {
......@@ -170,6 +175,8 @@
self.allowPickingVideo = YES;
self.allowPickingImage = YES;
self.allowTakePicture = YES;
self.allowTakeVideo = YES;
self.videoMaximumDuration = 10 * 60;
self.sortAscendingByModificationDate = YES;
self.autoDismiss = YES;
self.columnNumber = columnNumber;
......@@ -279,7 +286,7 @@
}
- (void)configDefaultImageName {
self.takePictureImageName = @"takePicture";
self.takePictureImageName = @"takePicture80";
self.photoSelImageName = @"photo_sel_photoPickerVc";
self.photoDefImageName = @"photo_def_photoPickerVc";
self.photoNumberIconImageName = @"photo_number_icon";
......@@ -625,7 +632,7 @@
[super viewWillAppear:animated];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc hideProgressHUD];
if (imagePickerVc.allowTakePicture) {
if (imagePickerVc.allowPickingImage) {
self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Photos"];
} else if (imagePickerVc.allowPickingVideo) {
self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Videos"];
......
......@@ -16,6 +16,7 @@
#import "TZVideoPlayerController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import <MobileCoreServices/MobileCoreServices.h>
@interface TZPhotoPickerController ()<UICollectionViewDataSource,UICollectionViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIAlertViewDelegate> {
NSMutableArray *_models;
......@@ -87,7 +88,7 @@ static CGFloat itemMargin = 5;
tzImagePickerVc.navLeftBarButtonSettingBlock(leftButton);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
}
_showTakePhotoBtn = (_model.isCameraRoll && tzImagePickerVc.allowTakePicture);
_showTakePhotoBtn = _model.isCameraRoll && (tzImagePickerVc.allowTakePicture || tzImagePickerVc.allowTakeVideo);
// [self resetCachedAssets];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
......@@ -153,7 +154,7 @@ static CGFloat itemMargin = 5;
_collectionView.alwaysBounceHorizontal = NO;
_collectionView.contentInset = UIEdgeInsetsMake(itemMargin, itemMargin, itemMargin, itemMargin);
if (_showTakePhotoBtn && tzImagePickerVc.allowTakePicture ) {
if (_showTakePhotoBtn) {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber) / self.columnNumber) * self.view.tz_width);
} else {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber - 1) / self.columnNumber) * self.view.tz_width);
......@@ -437,10 +438,7 @@ static CGFloat itemMargin = 5;
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (_showTakePhotoBtn) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowTakePicture) {
return _models.count + 1;
}
return _models.count + 1;
}
return _models.count;
}
......@@ -451,6 +449,13 @@ static CGFloat itemMargin = 5;
if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.row >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.row == 0)) && _showTakePhotoBtn) {
TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath];
cell.imageView.image = [UIImage imageNamedFromMyBundle:tzImagePickerVc.takePictureImageName];
if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) {
cell.imageView.contentMode = UIViewContentModeCenter;
CGFloat rgb = 223 / 255.0;
cell.imageView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
} else {
cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
}
return cell;
}
// the cell dipaly photo or video / 展示照片或视频的cell
......@@ -603,13 +608,19 @@ static CGFloat itemMargin = 5;
}];
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
self.imagePickerVc.sourceType = sourceType;
if ([UIImagePickerController isSourceTypeAvailable: sourceType]) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowPickingVideo) {
self.imagePickerVc.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
self.imagePickerVc.sourceType = sourceType;
NSMutableArray *mediaTypes = [NSMutableArray array];
if (tzImagePickerVc.allowTakePicture) {
[mediaTypes addObject:(NSString *)kUTTypeImage];
}
if (tzImagePickerVc.allowTakeVideo) {
[mediaTypes addObject:(NSString *)kUTTypeMovie];
self.imagePickerVc.videoMaximumDuration = tzImagePickerVc.videoMaximumDuration;
}
if(iOS8Later) {
self.imagePickerVc.mediaTypes= mediaTypes;
if (iOS8Later) {
_imagePickerVc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}
[self presentViewController:_imagePickerVc animated:YES completion:nil];
......@@ -673,10 +684,7 @@ static CGFloat itemMargin = 5;
if (tzImagePickerVc.sortAscendingByModificationDate) {
item = _models.count - 1;
if (_showTakePhotoBtn) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowTakePicture) {
item += 1;
}
item += 1;
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
......
......@@ -35,6 +35,7 @@
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
// 设置开关
@property (weak, nonatomic) IBOutlet UISwitch *showTakePhotoBtnSwitch; ///< 在内部显示拍照按钮
@property (weak, nonatomic) IBOutlet UISwitch *showTakeVideoBtnSwitch; ///< 在内部显示拍视频按钮
@property (weak, nonatomic) IBOutlet UISwitch *sortAscendingSwitch; ///< 照片排列按修改时间升序
@property (weak, nonatomic) IBOutlet UISwitch *allowPickingVideoSwitch; ///< 允许选择视频
@property (weak, nonatomic) IBOutlet UISwitch *allowPickingImageSwitch; ///< 允许选择图片
......@@ -105,7 +106,7 @@
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
NSInteger contentSizeH = 12 * 35 + 20;
NSInteger contentSizeH = 13 * 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);
});
......@@ -116,7 +117,8 @@
_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);
CGFloat collectionViewY = CGRectGetMaxY(self.scrollView.frame);
self.collectionView.frame = CGRectMake(0, collectionViewY, self.view.tz_width, self.view.tz_height - collectionViewY);
}
#pragma mark UICollectionView
......@@ -233,6 +235,8 @@
imagePickerVc.selectedAssets = _selectedAssets; // 目前已经选中的图片数组
}
imagePickerVc.allowTakePicture = self.showTakePhotoBtnSwitch.isOn; // 在内部显示拍照按钮
imagePickerVc.allowTakeVideo = self.showTakeVideoBtnSwitch.isOn; // 在内部显示拍视频按
imagePickerVc.videoMaximumDuration = 10; // 视频最大拍摄时间
// imagePickerVc.photoWidth = 1000;
......@@ -604,7 +608,12 @@
- (IBAction)showTakePhotoBtnSwitchClick:(UISwitch *)sender {
if (sender.isOn) {
[_showSheetSwitch setOn:NO animated:YES];
[_allowPickingImageSwitch setOn:YES animated:YES];
}
}
- (IBAction)showTakeVideoBtnSwitchClick:(UISwitch *)sender {
if (sender.isOn) {
[_showSheetSwitch setOn:NO animated:YES];
}
}
......@@ -626,7 +635,6 @@
- (IBAction)allowPickingImageSwitchClick:(UISwitch *)sender {
if (!sender.isOn) {
[_allowPickingOriginalPhotoSwitch setOn:NO animated:YES];
[_showTakePhotoBtnSwitch setOn:NO animated:YES];
[_allowPickingVideoSwitch setOn:YES animated:YES];
[_allowPickingGifSwitch setOn:NO animated:YES];
}
......
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