我必须Class method
从一个类调用一个类到另一个类,实际上进入类方法我必须通过UIImage
. 所以我创建了一个NSObject
并在Viewcontroller
按钮中调用它
如何调用UIImageView
以及在哪里..请检查我出错的代码..
我需要对调用图像的方法进行哪些更改
Zaction.h
@interface ZAction : NSObject
@property (retain) NSString *title;
@property (assign) id <NSObject> target;
@property (assign) SEL action;
@property (retain) id <NSObject> object;
@property(retain) UIImageView *image;
+ (ZAction *)actionWithTitle:(NSString *)aTitle target:(id)aTarget action:(SEL)aAction object:(id)aObject image:(UIImageView *)Aimage;;
ZAction.m
@implementation ZAction
@synthesize title;
@synthesize target;
@synthesize action;
@synthesize object,image;
+ (ZAction *)actionWithTitle:(NSString *)aTitle target:(id)aTarget action:(SEL)aAction object:(id)aObject image:(UIImageView *)Aimage;
{
ZAction *actionObject = [[[ZAction alloc] init] autorelease];
actionObject.title = aTitle;
actionObject.target = aTarget;
actionObject.action = aAction;
actionObject.object = aObject;
actionObject.image=Aimage;
return actionObject;
}
视图控制器.m
#import "Zaction.h"
- (IBAction)test4Action:(id)sender
{
UIImageView *image1=[[UIImageView alloc]initWithFrame:CGRectZero];
ZAction *destroy = [ZAction actionWithTitle:@"Clear" target:self action:@selector(colorAction:) object:[UIColor clearColor] image:image1];
ZAction *sec = [ZAction actionWithTitle:@"Unclear" target:self action:@selector(colorAction:) object:[UIColor clearColor] image:image1];
image1.image=[UIImage imageNamed:@"icon2.png"];
[self.view addSubview:image1];
ZActionSheet *sheet = [[[ZActionSheet alloc] initWithTitle:@"Title" cancelAction:nil destructiveAction:destroy
otherActions:[NSArray arrayWithObjects:option1, nil]] autorelease];
sheet.identifier = @"test4";
[sheet showFromBarButtonItem:sender animated:YES];
}