uiimageview

Error when trying to save image in NSUserDefaults using Swift

混江龙づ霸主 提交于 2019-12-17 19:25:53
问题 When i try to save an image in NSUserDefaults, the app crashed with this error. Why? Is it possible to save an image with NSUserDefaults? If not, then how do I save the image? Image... Code... var image1:UIImage = image1 var save1: NSUserDefaults = NSUserDefaults.standardUserDefaults() save1.setObject(Info.Image1, forKey: "Image1") save1.synchronize() Log error... libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) 回答1: NSUserDefaults isn't just a big truck you can

tap gesture not recognized on uiimageview

[亡魂溺海] 提交于 2019-12-17 18:15:57
问题 I added two uiimageview s, one on another subview uiview ( imageview1,imageview2 ). In the first view the top uiimageview is hidden( imageview2 ) and in the second view the bottom imageview is hidden( imageview1 ). Allocating tap gesture: UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneTap:)]; UITapGestureRecognizer *singleTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneTap:)]; Set user interaction for

UIImageView+AFNetworking setImageWithURL with animation

℡╲_俬逩灬. 提交于 2019-12-17 17:54:30
问题 With AFNetworking, is very simple to download an image from a server and put into an UIImageView: [imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]]; How about if I want to do this replacement of image with an effect (maybe fade)??? It's because I want to make a slideshow with a lot of images. 回答1: You can use animateWithDuration in conjunction with the rendition of setImageWithURL that supplies the

How to animate a UIImageview to display fullscreen by tapping on it?

房东的猫 提交于 2019-12-17 17:35:03
问题 I have an UIImageView in a UITableviewCell. When it is tapped, the UIImageView should animated to be displayed fullscreen. When the image is tapped when it is fullscreen it should shrink back to the original position. How can this be achieved? 回答1: Add a gesture recognizer to the view controller. Add the gesture Recognizer to your header file @interface viewController : UIViewController <UIGestureRecognizerDelegate>{ UITapGestureRecognizer *tap; BOOL isFullScreen; CGRect prevFrame; } In your

How to get the size of a scaled UIImage in UIImageView?

拜拜、爱过 提交于 2019-12-17 17:26:07
问题 The image.size attribute of UIImageView gives the size of the original UIImage . I would like to find out the size of the autoscaled image when it is put in the UIImageView (typically smaller than the original). For example, I have the image set to Aspect Fit . Now I want to know its new height and width on the screen so I can draw accurately on the new scaled image. Is there any way to do this without figuring it out myself based on the UIImageView size & UIImage original size (basically

Masking an image in Swift using CALayer and UIImage

a 夏天 提交于 2019-12-17 16:38:47
问题 I'm programming in Swift. I want to mask an image using CALayer and UIImage. I'm creating my mask image programmatically. The created mask image is a UIImage and works fine when I view it on its own. But when I use it as a mask the whole screen becomes white. I suspect that my problem is in configuring the CALayer object. I would appreciate your help. Thanks! class ViewController: UIViewController { @IBOutlet weak var imageView: UIImageView! override func viewDidLoad() { super.viewDidLoad() /

(iphone) UIImageView setImage: leaks?

筅森魡賤 提交于 2019-12-17 12:39:22
问题 i'm changing image of UIImageview by [self setImage: newImage]; Looks like every time I does that with newImage, prior image doesn't seem to be released. What's the correct way to replace image of UIImageView? Thank you 回答1: UIImageView setImage: never leaks, unless the image you are passing doesn't get released. Your code wont leak, if your are assigning an autoreleased image to the image view, something like the following. UIImage *newImage = [UIImage imageNamed:@"sampleImage"];

Change UIImageView size to match image with AutoLayout

蓝咒 提交于 2019-12-17 10:31:28
问题 I want to change my UIImageView height/width to match the image i choose from photo album and i found a snippet on here that does that. -(CGRect)frameForImage:(UIImage *)imgs inImageViewAspectFit:(UIImageView *)imagev { float imageRatio = imgs.size.width / imgs.size.height; float viewRatio = imagev.frame.size.width / imagev.frame.size.height; if(imageRatio < viewRatio) { float scale = imagev.frame.size.height / imgs.size.height; float width = scale * imgs.size.width; float topLeftX = (imagev

Change UIImageView size to match image with AutoLayout

痞子三分冷 提交于 2019-12-17 10:31:20
问题 I want to change my UIImageView height/width to match the image i choose from photo album and i found a snippet on here that does that. -(CGRect)frameForImage:(UIImage *)imgs inImageViewAspectFit:(UIImageView *)imagev { float imageRatio = imgs.size.width / imgs.size.height; float viewRatio = imagev.frame.size.width / imagev.frame.size.height; if(imageRatio < viewRatio) { float scale = imagev.frame.size.height / imgs.size.height; float width = scale * imgs.size.width; float topLeftX = (imagev

Creating a UIImage from a rotated UIImageView

强颜欢笑 提交于 2019-12-17 08:59:17
问题 I have a UIImageView with an image in it. I have rotated the image prior to display by setting the transform property of the UIImageView to CGAffineTransformMakeRotation(angle) where angle is the angle in radians. I want to be able to create another UIImage that corresponds to the rotated version that I can see in my view. I am almost there, by rotating the image context I get a rotated image: - (UIImage *) rotatedImageFromImageView: (UIImageView *) imageView { UIImage *rotatedImage; // Get