- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在设置图像时遇到问题。当从 imagePickerController 中获取图像时,我有一个代表告诉我。它将它发送到所有者 Controller ,然后我尝试在另一个 Controller 上设置图像。一切似乎都应该正常工作……但是每当我显示 View 时,图像都不存在。这是代码:
// this gets called when an image has been chosen from the library or taken from the camera
// it is in the viewController in charge of grabbing an image (.m file)
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
if(self.delegate)
{
[self.delegate didAcquirePicture:image];
}
}
//This is in the controller .m file
- (void)didAcquirePicture:(UIImage *)picture
{
if(picture != Nil)
{
self.photoEditView = [[PhotoEditViewController alloc] init];
[self.photoPicker.imagePickerController dismissModalViewControllerAnimated:NO];
[self.photoEditView.imageView setImage:picture];
[self presentModalViewController: self.photoEditView animated:NO];
}
}
//this is the photoEditViewController .h
#import <UIKit/UIKit.h>
@class PhotoEditViewController;
@protocol PhotoEditViewControllerDelegate
@end
@interface PhotoEditViewController : UIViewController {
IBOutlet UIImageView *imageView;
}
@property (retain) UIImageView *imageView;
@end
//this is the photoEditView .m file
#import "PhotoEditViewController.h"
@implementation PhotoEditViewController
@synthesize imageView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc {
[super dealloc];
[imageView dealloc];
}
@end
最佳答案
看起来有可能在您关闭 imagePickerController 时释放图像,然后再将其分配给 imageView。如果是这样,你可以修复它
[[图片保留]自动释放];
如前所述,针对 nil
而不是 Nil
进行测试。此外,最好使用 [self.delegate respondsToSelector: @selector(didAcquirePicture)];
— 请记住将消息发送到 nil
是安全的。
关于ios - setImage 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8219586/
我在设置图像时遇到问题。当从 imagePickerController 中获取图像时,我有一个代表告诉我。它将它发送到所有者 Controller ,然后我尝试在另一个 Controller 上设置
我需要使用线程来从网络检索图像并将其分配到 ImageView 中。 我对 NSOperation 进行了子类化,并从我的 View Controller 中调用它,如下所示: NSOperation
我有以下代码,当我调用此方法时,尽管资源中有图像,但它不会更改按钮的图像。 -(void)changeButton:(NSString*)button withURL:(NSString*)url {
我对这门语言完全陌生,我正在尝试了解 ImageIcon 的工作原理。我在子类中有一个方法,我想根据 switch 语句返回一个 ImageIcon。我遇到的唯一问题是我似乎无法让 .setImage
我有一个以编程方式创建的 UIImageView ([[UIImageView alloc] init])。应用程序的内存一直受到检查,直到 setImage:方法被调用。有什么想法吗? 最佳答案 我
我在代码中创建了两个UIImageView: UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(150, 6
我通过一个非常简单的函数遇到了内存泄漏问题。这是我的代码: -(void) drawPuzzle { gameView.image=nil; UIGraphics
我正在使用 setImage() 在 UIButton 上设置图像,但它不会立即更改图像。要显示图像,我需要再次单击该按钮或其他按钮。如何解决这个问题? block.setImage(UIImage(
我已经使用 setImage 来描述当前图像的状态,但我想在 setImage() 中同时使用两个状态。所以我想合并两个状态 .Highlighted & .Selected button.setIm
我正在编写一个音调生成器 UI,每次生成器开始生成和完成生成时,我都需要更改 UIImageView 图像。为此,我有 @property (weak, nonatomic) IBOutlet UII
我有一个类,其中有两个 UIImageView。在 if control 之后我正在设置这些 ImageView 的图像,但它没有设置。 我正在调用另一个类的方法。 我的代码如下, @synthesi
使用此代码设置按钮图像时出现问题: button.setImage(#imageLiteral(resourceName: "flight_deselect")**.changeToLightGray
我正在尝试制作自己的自定义 Facebook 登录按钮。我很接近,但出于某种原因,当我在 UIButton 上设置图像时,它仍然有一个非常大的框架,将文本推到右边,图标也推到右边。 我错过了什么?我尝
我正在尝试让 tesseract 在 python 中运行: ...image is a numpy array (uint8)... tessApi = tesseract.TessBaseAPI(
我正在使用 andEngine 为 Android 开发游戏。我必须动态更改 Sprite 图像。在 J2ME 中,我使用了 sprite.setImage("img.png"); 但是在andeng
我正在尝试使用 CMFCButton 中的函数 SetImage 为我的按钮加载位图。我没有得到任何错误或其他东西,只是一个普通的按钮。我正在对 icons 做同样的事情并且它有效,但我也需要它来加载
我用 ffmpeg 实现了一个视频播放器。每一帧都解码成功,可以保存为有效的jpg文件,在模拟器中运行时可以显示在UIImageView中。但是,当我在模拟器中运行我的应用程序时,内存会无限增长。此外
这个问题完全难住了我。这是适用于带有 Xcode 4.2 的 iOS 5.0 发生的事情是,在我的应用程序中,我让用户从他们的相册中选择图像,并将这些图像保存到应用程序文档目录中。非常简单。 然后我所
我正在尝试使用以下方法从本地 URL 加载图像: UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:fileU
一直在寻找这个问题的解决方案已经无数个小时了。问题其实很简单。我在 nib 中有一个 UIImageView,我正在从互联网加载图像并使用该图像设置 UIIImageView。我正在释放 viewCo
我是一名优秀的程序员,十分优秀!