I'v thought that dealing with UIPasteboard is easy but it turned out to be a time-consuming issue...
I want to store an UIImage in UIPasteboard and then paste this image in iMessage, WhatsApp, Gmail... and others.
That's my method where I use UIPasteboard
- (void) postClipboard
{
if ([[modelView currentView] isImage])
{
UIImage *image = [self readyImageLandscape:orientationLandscape];
[[UIPasteboard generalPasteboard] setImage:image];
}
}
It works on iPhone 3GS 5.1. I've tested it on Gmail and WhatsApp
Then I modified the method to
- (void) postClipboard
{
if ([[modelView currentView] isImage])
{
UIImage *image = [self readyImageLandscape:orientationLandscape];
[[UIPasteboard generalPasteboard] setImage:image];
[[UIPasteboard generalPasteboard] setPersistent:YES];
}
}
Still works on iPhone 3GS 5.1.
But my employer says that it doesn't work on iPhone 4S 6.0 neither in WhatsApp nor in any other application.
Am I doing all wrong or there should be another approach to make it work on iPhone 4S 6.0?
See this answer: https://stackoverflow.com/a/12613632/830946
Looks like that code will work with a single image, but not with multiple.
Related
When I try to load printer in objective c code the printer view goes out of the screen. Can anybody look into this?
I have tried with delegate methods of UIPrintInteractionController
but presenting the printer controller goes to out of the screen.
This code works properly in ios 12 I want the same printer screen in ios 13
UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
[printController presentFromRect:self.actionsButton.frame inView:self.view animated:NO
completionHandler:^(UIPrintInteractionController
*printInteractionController, BOOL completed, NSError *error) {
if (completed) {
[self.actionsPopoverController dismissPopoverAnimated:YES];
self.actionsPopoverController = nil;
}
}];
Screen Short Below
I have faced the same issue. But this an OS issue for iOS 13. This issue has been fixed by Apple for iOS 13.1 beta. Try to run your code in iOS 13.1 beta
thanks helping me I am poor in English.
Calling this method every 1 min from NSTimer. I need capture Activity happens in iPhone, not my application.... I tried with bellow code it will take my application screen.... I need to take iPhone screen short...
example user opens safari and types URLthen I need to take that screen capture from my app it is possible.
if it is possible how to achieve that.
if ([[UIScreen mainScreen] respondsToSelector:#selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
} else {
UIGraphicsBeginImageContext(self.window.bounds.size);
}
[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = UIImagePNGRepresentation(image);
if (imageData) {
[imageData writeToFile:#"screenshot.png" atomically:YES];
} else {
NSLog(#"error while taking screenshot");
}
The Answer is NO.
Support for background execution must be declared in advance by the app that uses them.
Below are the Background modes for apps
Please read this link for more information : iOS BackgroundExecution
As weird as it sounds...
App loaded through test flight or iTunes does not show image on the screen, but it does when it is loaded through Xcode. I believe the UIImageView is there, and the UIImage is loaded.
App loaded through the Xcode works.
If the device is connected to the Xcode and debugging, device connected with USB cable. App works despite the load method...
Core data seems to works in all cases.
Any idea, somebody has seen something similar. I am quite lost.
Also if you have any tip on how to debug this on the device I will appreciate it.
The few code I think it is involve.
I am loading the UIImage from disk using
UIImage * previewImage = [UIImage imageWithContentsOfFile:path];
The image is located in Documents Directory fileName is the input
NSURL *documentsFolderURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSString *documentsFolderPath = [documentsFolderURL path];
if (![_documentsDirectory isEqualToString:documentsFolderPath]) [self generateLocaFolderPath];
NSString *returnedPath = [_documentsDirectory stringByAppendingPathComponent:fileName];
return returnedPath;
and setting the image in the imageView with
previewView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frameImageThumbnail.size.width, frameImageThumbnail.size.height)];
[previewView setImage:previewImage];
Everything else seems to work well...
My first question!!! Thanks for reading!
_ edit _
I had the strong believe now that the problem is not in the UIImage, I have use the same methods in other parts of the app and it is working fine.
But now I believe the problem is in the animation I perform to the UIView that contains the UIImageView.
[_view setFrame:frameImageThumbnail];
[_view setClipsToBounds:YES];
[_view setAutoresizesSubviews:YES];
[_image setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[_view addSubview:_image];
[UIView animateWithDuration:0.4
delay:0.1
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void){
CGRect destination1Frame = _view.frame;
//... some complicated calculations with the rect ...
[_view setFrame:destination1Frame];
[UIView transitionFromView:_customView toView:_view duration:0 options: UIViewAnimationOptionShowHideTransitionViews completion:^(BOOL finisehdCompletion){
//stop showing video in _customView
}];
}];
I am using NSAutolayout in the storyboard. Though my application only allows one landscape orientation. No idea if all this meshing up with the frames it is making.
dizzy to the poor auto layout guy...
Make sure you have / your image is set in Copy Bundle Resources. You can check if your image path is valid also. But I think the image is not set to copy at Build Phases.
I had the same problem.. Haven't find a correct solution.
But I deleted the image(check if it's deleted in ur Bundle resources), then put the image again, with ANOTHER name.
It worked for me. It's a temporary solution, idk if it's an apple bug or what.
Ok After more than 20 ipa files build and installed in my devices. In all this process to get rid of the problem I removed the _view from the storyboard, and initiallize the view programmatically. I remember that _view was originally set to (weak, nonatomic) property because was made with the storyboard, this super nice ctrl+.
That was I change I made, weak to Strong, and works now.
I don't know why it didn't work only when the program was install through iTunes with the ipa file or through the test flight app. That is still a mystery to me.
i have written an App that takes screenshots. If the user enables this feature the app uses a background queue to take screenshots.
In iOS7 everything works fine but with iOS 8 there are only send white Screenshots to the server.
I use this method to take a screenshot:
CGImageRef cgScreen = UIGetScreenImage();
if (cgScreen) {
result = [UIImage imageWithCGImage:cgScreen];
CGImageRelease(cgScreen);
}
Does anyone have an idea to solve the problem?
Unfortunately I could not find the Apple's official documentation about the method UIGetScreenImage() but I have read so many stackoverflow entries saying that has been removed in iOS8 and especially iOS7 with 64bit binaries.
I am using following method to make screenshot and which is working from iOS 5 to iOS 8 without any problem.
- (void)makeScreenShotWithView:(UIView *)view scale:(float)scale {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
if you want to make the whole screen as screenshot then pass a window object for an example view.window.
Try this
I have quick question. I am using the following code to launch camera and record video on iOS 4.x devices, it works great. I want to use the same code on iPad 2 device as iPad 2 has video recording facility. Will it work? Can someone please guide me?
if ([types containsObject:(id)kUTTypeMovie])
{
UIImagePickerController *pickerController = [[[UIImagePickerController alloc] init] autorelease];
pickerController.delegate = self;
pickerController.videoQuality = appDelegate.settingsCtrler.quality;
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.showsCameraControls = YES;
pickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];
pickerController.videoMaximumDuration = maxDuration;
[appDelegate hideFloatingBar];
[self presentModalViewController:pickerController animated:YES];
}
Thank you in Advance!
If it builds on iOS 4.3 you should be OK - although I don't have an iPad2 to test it on. I would wrap the logic in a test though:
if([picker isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
// Your code here.
}
so that it doesn't try and present a camera when one isn't available.