将UIImage从一个类发送到另一个类

时间:2011-12-05 22:26:35

标签: iphone objective-c ios uiimage

我想将UIImage从一个类发送到另一个类。 在FirstViewController.m中我写了这段代码

 FormViewController *formViewController =[[FormViewController alloc]initWithNibName:@"FormViewController" bundle:nil];
formViewController.userImage=imageFb;
    [formViewController.userImage retain];
 [self presentModalViewController:formViewController animated:YES];

错误是

  

成员'userImage'的请求不是结构或联合

在FormViewController.h中

@interface FormViewController : UIViewController
{
    UIImageView *photo;
    UIimage *userImage;

}
@property(retain,nonatomic)  UIimage *userImage;
@property(retain,nonatomic) IBOutlet UIImageView *photo;   

我收到此错误

  

UIimage之前的预期说明符限定符列表

FormViewController.m中的

- (void)viewDidLoad
{
[super viewDidLoad];
    [photo setImage:userImage];
}

,错误是

  

userImage unclared(首次在此函数中使用)

2 个答案:

答案 0 :(得分:5)

它是UIImage,而不是UIimage

答案 1 :(得分:0)

转换NSData中的图片 而不是将NSData对象分配给类型为NSData

的另一个类属性
NSData *imgdata = UIImageJPEGRepresentation(topImage, 1.0);

然后按照以下方式将NSData属性转换为图像

imageview.image = [[UIImage alloc] initWithData:imgdata];
相关问题