зеркало из https://github.com/nextcloud/talk-ios.git
Upload and share files using ShareConfirmation view controller.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
2c77425290
Коммит
a1882b7047
|
@ -15,7 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
typedef enum ShareConfirmationType {
|
typedef enum ShareConfirmationType {
|
||||||
ShareConfirmationTypeText = 0,
|
ShareConfirmationTypeText = 0,
|
||||||
ShareConfirmationTypeImage
|
ShareConfirmationTypeImage,
|
||||||
|
ShareConfirmationTypeFile
|
||||||
} ShareConfirmationType;
|
} ShareConfirmationType;
|
||||||
|
|
||||||
@class ShareConfirmationViewController;
|
@class ShareConfirmationViewController;
|
||||||
|
@ -37,6 +38,8 @@ typedef enum ShareConfirmationType {
|
||||||
@property (strong, nonatomic) NSString *sharedText;
|
@property (strong, nonatomic) NSString *sharedText;
|
||||||
@property (strong, nonatomic) NSString *sharedImageName;
|
@property (strong, nonatomic) NSString *sharedImageName;
|
||||||
@property (strong, nonatomic) UIImage *sharedImage;
|
@property (strong, nonatomic) UIImage *sharedImage;
|
||||||
|
@property (strong, nonatomic) NSString *sharedFileName;
|
||||||
|
@property (strong, nonatomic) NSData *sharedFile;
|
||||||
@property (assign, nonatomic) BOOL isModal;
|
@property (assign, nonatomic) BOOL isModal;
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +47,8 @@ typedef enum ShareConfirmationType {
|
||||||
@property (weak, nonatomic) IBOutlet UITextView *toTextView;
|
@property (weak, nonatomic) IBOutlet UITextView *toTextView;
|
||||||
@property (weak, nonatomic) IBOutlet UITextView *shareTextView;
|
@property (weak, nonatomic) IBOutlet UITextView *shareTextView;
|
||||||
@property (weak, nonatomic) IBOutlet UIImageView *shareImageView;
|
@property (weak, nonatomic) IBOutlet UIImageView *shareImageView;
|
||||||
|
@property (weak, nonatomic) IBOutlet UIImageView *shareFileImageView;
|
||||||
|
@property (weak, nonatomic) IBOutlet UITextView *shareFileTextView;
|
||||||
|
|
||||||
- (id)initWithRoom:(NCRoom *)room account:(TalkAccount *)account serverCapabilities:(ServerCapabilities *)serverCapabilities;
|
- (id)initWithRoom:(NCRoom *)room account:(TalkAccount *)account serverCapabilities:(ServerCapabilities *)serverCapabilities;
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,8 @@
|
||||||
[self sendSharedText];
|
[self sendSharedText];
|
||||||
} else if (_type == ShareConfirmationTypeImage) {
|
} else if (_type == ShareConfirmationTypeImage) {
|
||||||
[self sendSharedImage];
|
[self sendSharedImage];
|
||||||
|
} else if (_type == ShareConfirmationTypeFile) {
|
||||||
|
[self sendSharedFile];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self startAnimatingSharingIndicator];
|
[self startAnimatingSharingIndicator];
|
||||||
|
@ -111,7 +113,6 @@
|
||||||
self.type = ShareConfirmationTypeText;
|
self.type = ShareConfirmationTypeText;
|
||||||
self.shareTextView.text = _sharedText;
|
self.shareTextView.text = _sharedText;
|
||||||
self.shareTextView.editable = NO;
|
self.shareTextView.editable = NO;
|
||||||
self.shareImageView.hidden = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSharedImage:(UIImage *)sharedImage
|
- (void)setSharedImage:(UIImage *)sharedImage
|
||||||
|
@ -121,10 +122,30 @@
|
||||||
self.type = ShareConfirmationTypeImage;
|
self.type = ShareConfirmationTypeImage;
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.shareImageView setImage:self->_sharedImage];
|
[self.shareImageView setImage:self->_sharedImage];
|
||||||
self.shareTextView.hidden = YES;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setSharedFileName:(NSString *)sharedFileName
|
||||||
|
{
|
||||||
|
_sharedFileName = sharedFileName;
|
||||||
|
|
||||||
|
self.shareFileTextView.text = _sharedFileName;
|
||||||
|
self.shareFileTextView.editable = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setSharedFile:(NSData *)sharedFile
|
||||||
|
{
|
||||||
|
_sharedFile = sharedFile;
|
||||||
|
|
||||||
|
[self.shareFileImageView setImage:[UIImage imageNamed:@"file"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setType:(ShareConfirmationType)type
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
[self setUIForShareType:_type];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setIsModal:(BOOL)isModal
|
- (void)setIsModal:(BOOL)isModal
|
||||||
{
|
{
|
||||||
_isModal = isModal;
|
_isModal = isModal;
|
||||||
|
@ -181,6 +202,41 @@
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)sendSharedFile
|
||||||
|
{
|
||||||
|
NSString *attachmentsFolder = _serverCapabilities.attachmentsFolder ? _serverCapabilities.attachmentsFolder : @"";
|
||||||
|
NSString *filePath = [NSString stringWithFormat:@"%@/%@", attachmentsFolder, _sharedFileName];
|
||||||
|
NSString *fileServerURL = [NSString stringWithFormat:@"%@/%@%@", _account.server, _serverCapabilities.webDAVRoot, filePath];
|
||||||
|
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
|
||||||
|
NSURL *fileLocalURL = [[tmpDirURL URLByAppendingPathComponent:@"file"] URLByAppendingPathExtension:@"data"];
|
||||||
|
[_sharedFile writeToFile:[fileLocalURL path] atomically:YES];
|
||||||
|
|
||||||
|
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||||
|
hud.mode = MBProgressHUDModeAnnularDeterminate;
|
||||||
|
hud.label.text = @"Uploading file";
|
||||||
|
|
||||||
|
[[NCCommunication shared] uploadWithServerUrlFileName:fileServerURL fileNameLocalPath:[fileLocalURL path] dateCreationFile:nil dateModificationFile:nil customUserAgent:nil addCustomHeaders:nil progressHandler:^(NSProgress * progress) {
|
||||||
|
hud.progress = progress.fractionCompleted;
|
||||||
|
} completionHandler:^(NSString *account, NSString *ocId, NSString *etag, NSDate *date, int64_t size, NSInteger errorCode, NSString *errorDescription) {
|
||||||
|
NSLog(@"Upload completed with error code: %ld", (long)errorCode);
|
||||||
|
[hud hideAnimated:YES];
|
||||||
|
if (errorCode == 0) {
|
||||||
|
[[NCAPIController sharedInstance] shareFileOrFolderForAccount:self->_account atPath:filePath toRoom:self->_room.token withCompletionBlock:^(NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
[self.delegate shareConfirmationViewControllerDidFailed:self];
|
||||||
|
NSLog(@"Failed to send shared file");
|
||||||
|
} else {
|
||||||
|
[self.delegate shareConfirmationViewControllerDidFinish:self];
|
||||||
|
}
|
||||||
|
[self stopAnimatingSharingIndicator];
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
[self.delegate shareConfirmationViewControllerDidFailed:self];
|
||||||
|
}
|
||||||
|
[self stopAnimatingSharingIndicator];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - User Interface
|
#pragma mark - User Interface
|
||||||
|
|
||||||
- (void)startAnimatingSharingIndicator
|
- (void)startAnimatingSharingIndicator
|
||||||
|
@ -195,6 +251,38 @@
|
||||||
self.navigationItem.rightBarButtonItem = _sendButton;
|
self.navigationItem.rightBarButtonItem = _sendButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setUIForShareType:(ShareConfirmationType)shareConfirmationType
|
||||||
|
{
|
||||||
|
switch (shareConfirmationType) {
|
||||||
|
case ShareConfirmationTypeText:
|
||||||
|
{
|
||||||
|
self.shareTextView.hidden = NO;
|
||||||
|
self.shareImageView.hidden = YES;
|
||||||
|
self.shareFileImageView.hidden = YES;
|
||||||
|
self.shareFileTextView.hidden = YES;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ShareConfirmationTypeImage:
|
||||||
|
{
|
||||||
|
self.shareTextView.hidden = YES;
|
||||||
|
self.shareImageView.hidden = NO;
|
||||||
|
self.shareFileImageView.hidden = YES;
|
||||||
|
self.shareFileTextView.hidden = YES;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ShareConfirmationTypeFile:
|
||||||
|
{
|
||||||
|
self.shareTextView.hidden = YES;
|
||||||
|
self.shareImageView.hidden = YES;
|
||||||
|
self.shareFileImageView.hidden = NO;
|
||||||
|
self.shareFileTextView.hidden = NO;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - NCCommunicationCommon Delegate
|
#pragma mark - NCCommunicationCommon Delegate
|
||||||
|
|
||||||
- (void)authenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
|
- (void)authenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="iOS"/>
|
<deployment identifier="iOS"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17124"/>
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||||
<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>
|
||||||
<objects>
|
<objects>
|
||||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ShareConfirmationViewController">
|
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ShareConfirmationViewController">
|
||||||
<connections>
|
<connections>
|
||||||
|
<outlet property="shareFileImageView" destination="5QM-q4-3rz" id="bRC-rU-qqg"/>
|
||||||
|
<outlet property="shareFileTextView" destination="Dak-dL-eGs" id="Xgp-xQ-TAz"/>
|
||||||
<outlet property="shareImageView" destination="MWY-NH-jyC" id="VP1-ek-up2"/>
|
<outlet property="shareImageView" destination="MWY-NH-jyC" id="VP1-ek-up2"/>
|
||||||
<outlet property="shareTextView" destination="nd6-Tq-h5e" id="Dzc-cu-QJt"/>
|
<outlet property="shareTextView" destination="nd6-Tq-h5e" id="Dzc-cu-QJt"/>
|
||||||
<outlet property="toBackgroundView" destination="ZlP-A7-sH2" id="DFl-6K-ybn"/>
|
<outlet property="toBackgroundView" destination="ZlP-A7-sH2" id="DFl-6K-ybn"/>
|
||||||
|
@ -30,27 +33,47 @@
|
||||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" editable="NO" text="To:" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zFH-sS-bfQ">
|
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" editable="NO" text="To:" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zFH-sS-bfQ">
|
||||||
<rect key="frame" x="20" y="0.0" width="374" height="36"/>
|
<rect key="frame" x="20" y="0.0" width="374" height="36"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||||
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
|
<color key="textColor" systemColor="labelColor"/>
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||||
</textView>
|
</textView>
|
||||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="nd6-Tq-h5e">
|
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="nd6-Tq-h5e">
|
||||||
<rect key="frame" x="20" y="56" width="374" height="718"/>
|
<rect key="frame" x="20" y="56" width="374" height="718"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||||
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
|
<color key="textColor" systemColor="labelColor"/>
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||||
</textView>
|
</textView>
|
||||||
|
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Dak-dL-eGs">
|
||||||
|
<rect key="frame" x="20" y="164" width="374" height="622"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||||
|
<color key="textColor" systemColor="labelColor"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||||
|
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||||
|
</textView>
|
||||||
|
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="5QM-q4-3rz">
|
||||||
|
<rect key="frame" x="20" y="56" width="100" height="100"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
</imageView>
|
||||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MWY-NH-jyC">
|
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MWY-NH-jyC">
|
||||||
<rect key="frame" x="20" y="44" width="374" height="730"/>
|
<rect key="frame" x="20" y="44" width="374" height="730"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
</imageView>
|
</imageView>
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
|
||||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
|
|
||||||
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
|
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||||
|
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
|
||||||
<point key="canvasLocation" x="137.68115942028987" y="124.55357142857142"/>
|
<point key="canvasLocation" x="137.68115942028987" y="124.55357142857142"/>
|
||||||
</view>
|
</view>
|
||||||
</objects>
|
</objects>
|
||||||
|
<resources>
|
||||||
|
<systemColor name="labelColor">
|
||||||
|
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
</systemColor>
|
||||||
|
<systemColor name="systemBackgroundColor">
|
||||||
|
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
</systemColor>
|
||||||
|
</resources>
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -767,12 +767,53 @@ typedef enum NCChatMessageAction {
|
||||||
|
|
||||||
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
|
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
|
||||||
{
|
{
|
||||||
|
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
|
||||||
|
ServerCapabilities *serverCapabilities = [[NCDatabaseManager sharedInstance] serverCapabilitiesForAccountId:activeAccount.accountId];
|
||||||
|
ShareConfirmationViewController *shareConfirmationVC = [[ShareConfirmationViewController alloc] initWithRoom:_room account:activeAccount serverCapabilities:serverCapabilities];
|
||||||
|
shareConfirmationVC.delegate = self;
|
||||||
|
shareConfirmationVC.isModal = YES;
|
||||||
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:shareConfirmationVC];
|
||||||
|
|
||||||
|
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
|
||||||
|
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
|
||||||
|
__block NSError *error;
|
||||||
|
[coordinator coordinateReadingItemAtURL:url options:NSFileCoordinatorReadingForUploading error:&error byAccessor:^(NSURL *newURL) {
|
||||||
|
NSString *fileName = [url lastPathComponent];
|
||||||
|
NSData *data = [NSData dataWithContentsOfURL:newURL];
|
||||||
|
[self presentViewController:navigationController animated:YES completion:^{
|
||||||
|
shareConfirmationVC.type = ShareConfirmationTypeFile;
|
||||||
|
shareConfirmationVC.sharedFileName = fileName;
|
||||||
|
shareConfirmationVC.sharedFile = data;
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls
|
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls
|
||||||
{
|
{
|
||||||
|
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
|
||||||
|
ServerCapabilities *serverCapabilities = [[NCDatabaseManager sharedInstance] serverCapabilitiesForAccountId:activeAccount.accountId];
|
||||||
|
ShareConfirmationViewController *shareConfirmationVC = [[ShareConfirmationViewController alloc] initWithRoom:_room account:activeAccount serverCapabilities:serverCapabilities];
|
||||||
|
shareConfirmationVC.delegate = self;
|
||||||
|
shareConfirmationVC.isModal = YES;
|
||||||
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:shareConfirmationVC];
|
||||||
|
|
||||||
|
// Just grab the first item for now
|
||||||
|
NSURL *url = urls.firstObject;
|
||||||
|
|
||||||
|
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
|
||||||
|
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
|
||||||
|
__block NSError *error;
|
||||||
|
[coordinator coordinateReadingItemAtURL:url options:NSFileCoordinatorReadingForUploading error:&error byAccessor:^(NSURL *newURL) {
|
||||||
|
NSString *fileName = [url lastPathComponent];
|
||||||
|
NSData *data = [NSData dataWithContentsOfURL:newURL];
|
||||||
|
[self presentViewController:navigationController animated:YES completion:^{
|
||||||
|
shareConfirmationVC.type = ShareConfirmationTypeFile;
|
||||||
|
shareConfirmationVC.sharedFileName = fileName;
|
||||||
|
shareConfirmationVC.sharedFile = data;
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller
|
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller
|
||||||
|
|
Загрузка…
Ссылка в новой задаче