English 中文(简体)
改变UIImage的形象 观点
原标题:Can t change image of UIImageView

页: 1

IBOutlet UIImageView *photoImageView;
UIImage *photo;

上午(在WillAppear)

photoImageView.image = photo;

在出现意见后,我可以修改<条码>。 采用:

photoImageView.image = [UIImage imageNamed:@"XXX.png"];

但修改了<代码>photo工程的价值。

photo = [UIImage imageNamed:@"XXX.png"];

How does it work?

问题回答

引证该法典。

//YourController.h

@interface YourController : UIViewController
{
    UIImageView* _photoImageView;
}

@property (retain, nonatomic) IBOutlet UIImageView *photoImageView;

- (IBAction)changeImageAction:(id)sender;

@end

//YourController.m

@synthesize photoImageView = _photoImageView;

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.photoImageView.image = [UIImage imageNamed:@"img.png"];
}

- (IBAction)changeImageAction:(id)sender {

    self.photoImageView.image = [UIImage imageNamed:@"img_2.png"];
}

www.un.org/Depts/DGACM/index_spanish.htm 一些说明:。

首先,你必须把<条码>磷酸盐/条码>联系起来。 IBOutlet在XCode正确。 为测试目的,我创建了一个与<代码>相联系的测试纽吨(UIButton)。 IBAction。 和测试纽扣(与IB共同创建)为<代码>YourController。

Remember to import your images into your project and to release memory in dealloc and in viewDidUnload.

- (dealloc)
{
   [_photoImageView release];
   _photoImageView = nil;

   [super dealloc]
}

- (void)viewDidUnload
{
   [super viewDidUnload];

   self.photoImageView = nil;
}

希望会有所助益。

<><>Edit>/strong>

该法典并非以阿农研中心为导向,但经过几处修改,有可能与阿农研中心一起实施。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签