swift 4, Using UIActivityViewController to share image to facebook and other app crashes
In my app I am trying to share large images to another apps. But when I send a large size image to like facebook the facebook comes up but it crashes. When I resize the image to a small size it doesn't crash.
I tried to share large images in the camera roll but in the camera roll it doesn't crash and shares it with original image size.
Is there a different way to do this using UIActivityViewController?
var shareImage = UIImage
shareImage.removeAll()
for i in 0...deletePhotoArray.count - 1 {
let asset = AlbumModel.allPhotos?.object(at: deletePhotoArray[i])
let options = PHImageRequestOptions()
options.version = .current
options.isSynchronous = true
options.deliveryMode = .fastFormat
PHImageManager.default().requestImage(for: asset!, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: options) { (image, info) in
shareImage.append(image!)
}
}
let activityViewController = UIActivityViewController(activityItems: shareImage, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
ios swift uiactivityviewcontroller
add a comment |
In my app I am trying to share large images to another apps. But when I send a large size image to like facebook the facebook comes up but it crashes. When I resize the image to a small size it doesn't crash.
I tried to share large images in the camera roll but in the camera roll it doesn't crash and shares it with original image size.
Is there a different way to do this using UIActivityViewController?
var shareImage = UIImage
shareImage.removeAll()
for i in 0...deletePhotoArray.count - 1 {
let asset = AlbumModel.allPhotos?.object(at: deletePhotoArray[i])
let options = PHImageRequestOptions()
options.version = .current
options.isSynchronous = true
options.deliveryMode = .fastFormat
PHImageManager.default().requestImage(for: asset!, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: options) { (image, info) in
shareImage.append(image!)
}
}
let activityViewController = UIActivityViewController(activityItems: shareImage, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
ios swift uiactivityviewcontroller
did you trynetworkAccessAllowed
totrue
of PHImageRequestOptions ?
– Prashant Tukadiya
Jan 2 at 4:36
@PrashantTukadiya Why do I have to do true for that option? It says "A Boolean value that specifies whether Photos can download the requested image from iCloud"
– David
Jan 2 at 6:34
I got such issue where my App was crashing because actual image was not available when user select or tap on it. so With this option true I am able to fix this
– Prashant Tukadiya
Jan 2 at 6:36
@PrashantTukadiya I tried that option but it was same for me :(
– David
Jan 3 at 3:14
add a comment |
In my app I am trying to share large images to another apps. But when I send a large size image to like facebook the facebook comes up but it crashes. When I resize the image to a small size it doesn't crash.
I tried to share large images in the camera roll but in the camera roll it doesn't crash and shares it with original image size.
Is there a different way to do this using UIActivityViewController?
var shareImage = UIImage
shareImage.removeAll()
for i in 0...deletePhotoArray.count - 1 {
let asset = AlbumModel.allPhotos?.object(at: deletePhotoArray[i])
let options = PHImageRequestOptions()
options.version = .current
options.isSynchronous = true
options.deliveryMode = .fastFormat
PHImageManager.default().requestImage(for: asset!, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: options) { (image, info) in
shareImage.append(image!)
}
}
let activityViewController = UIActivityViewController(activityItems: shareImage, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
ios swift uiactivityviewcontroller
In my app I am trying to share large images to another apps. But when I send a large size image to like facebook the facebook comes up but it crashes. When I resize the image to a small size it doesn't crash.
I tried to share large images in the camera roll but in the camera roll it doesn't crash and shares it with original image size.
Is there a different way to do this using UIActivityViewController?
var shareImage = UIImage
shareImage.removeAll()
for i in 0...deletePhotoArray.count - 1 {
let asset = AlbumModel.allPhotos?.object(at: deletePhotoArray[i])
let options = PHImageRequestOptions()
options.version = .current
options.isSynchronous = true
options.deliveryMode = .fastFormat
PHImageManager.default().requestImage(for: asset!, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: options) { (image, info) in
shareImage.append(image!)
}
}
let activityViewController = UIActivityViewController(activityItems: shareImage, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
ios swift uiactivityviewcontroller
ios swift uiactivityviewcontroller
edited Jan 2 at 3:30
rmaddy
243k27321383
243k27321383
asked Jan 2 at 3:29
DavidDavid
2
2
did you trynetworkAccessAllowed
totrue
of PHImageRequestOptions ?
– Prashant Tukadiya
Jan 2 at 4:36
@PrashantTukadiya Why do I have to do true for that option? It says "A Boolean value that specifies whether Photos can download the requested image from iCloud"
– David
Jan 2 at 6:34
I got such issue where my App was crashing because actual image was not available when user select or tap on it. so With this option true I am able to fix this
– Prashant Tukadiya
Jan 2 at 6:36
@PrashantTukadiya I tried that option but it was same for me :(
– David
Jan 3 at 3:14
add a comment |
did you trynetworkAccessAllowed
totrue
of PHImageRequestOptions ?
– Prashant Tukadiya
Jan 2 at 4:36
@PrashantTukadiya Why do I have to do true for that option? It says "A Boolean value that specifies whether Photos can download the requested image from iCloud"
– David
Jan 2 at 6:34
I got such issue where my App was crashing because actual image was not available when user select or tap on it. so With this option true I am able to fix this
– Prashant Tukadiya
Jan 2 at 6:36
@PrashantTukadiya I tried that option but it was same for me :(
– David
Jan 3 at 3:14
did you try
networkAccessAllowed
to true
of PHImageRequestOptions ?– Prashant Tukadiya
Jan 2 at 4:36
did you try
networkAccessAllowed
to true
of PHImageRequestOptions ?– Prashant Tukadiya
Jan 2 at 4:36
@PrashantTukadiya Why do I have to do true for that option? It says "A Boolean value that specifies whether Photos can download the requested image from iCloud"
– David
Jan 2 at 6:34
@PrashantTukadiya Why do I have to do true for that option? It says "A Boolean value that specifies whether Photos can download the requested image from iCloud"
– David
Jan 2 at 6:34
I got such issue where my App was crashing because actual image was not available when user select or tap on it. so With this option true I am able to fix this
– Prashant Tukadiya
Jan 2 at 6:36
I got such issue where my App was crashing because actual image was not available when user select or tap on it. so With this option true I am able to fix this
– Prashant Tukadiya
Jan 2 at 6:36
@PrashantTukadiya I tried that option but it was same for me :(
– David
Jan 3 at 3:14
@PrashantTukadiya I tried that option but it was same for me :(
– David
Jan 3 at 3:14
add a comment |
1 Answer
1
active
oldest
votes
Asking for targetSize: PHImageManagerMaximumSize
is certainly going to get you an extremely large image! So the first piece of advice is: don't do that.
You might be able to provide the data piecemeal over time by using a UIActivityItemProvider subclass.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000910%2fswift-4-using-uiactivityviewcontroller-to-share-image-to-facebook-and-other-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Asking for targetSize: PHImageManagerMaximumSize
is certainly going to get you an extremely large image! So the first piece of advice is: don't do that.
You might be able to provide the data piecemeal over time by using a UIActivityItemProvider subclass.
add a comment |
Asking for targetSize: PHImageManagerMaximumSize
is certainly going to get you an extremely large image! So the first piece of advice is: don't do that.
You might be able to provide the data piecemeal over time by using a UIActivityItemProvider subclass.
add a comment |
Asking for targetSize: PHImageManagerMaximumSize
is certainly going to get you an extremely large image! So the first piece of advice is: don't do that.
You might be able to provide the data piecemeal over time by using a UIActivityItemProvider subclass.
Asking for targetSize: PHImageManagerMaximumSize
is certainly going to get you an extremely large image! So the first piece of advice is: don't do that.
You might be able to provide the data piecemeal over time by using a UIActivityItemProvider subclass.
answered Jan 2 at 3:42
mattmatt
330k46536736
330k46536736
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000910%2fswift-4-using-uiactivityviewcontroller-to-share-image-to-facebook-and-other-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
did you try
networkAccessAllowed
totrue
of PHImageRequestOptions ?– Prashant Tukadiya
Jan 2 at 4:36
@PrashantTukadiya Why do I have to do true for that option? It says "A Boolean value that specifies whether Photos can download the requested image from iCloud"
– David
Jan 2 at 6:34
I got such issue where my App was crashing because actual image was not available when user select or tap on it. so With this option true I am able to fix this
– Prashant Tukadiya
Jan 2 at 6:36
@PrashantTukadiya I tried that option but it was same for me :(
– David
Jan 3 at 3:14