我有以下代码在 AppDelegate.h/.m 中工作,但无法将其更改为在 ViewController 中使用按钮触发它。
@implementation BSViewController
@synthesize imageView;
@synthesize workingImage;
- (IBAction) chooseImage:(id) sender {
UIImage* testCard = [UIImage imageNamed:@"ipad 7D.JPG"];
CGImageRef num = CGImageCreateWithImageInRect([testCard CGImage],CGRectMake(532, 0, 104, 104));
UIGraphicsBeginImageContext(CGSizeMake( 250,650));
CGContextRef con = UIGraphicsGetCurrentContext();
UIImage* im = UIGraphicsGetImageFromCurrentImageContext();
CGContextDrawImage(con, CGRectMake(0, 0, 13, 13) ,num);
UIGraphicsEndImageContext();
CGImageRelease(num);
UIImageView* iv = [[UIImageView alloc] initWithImage:im];
[self.imageView addSubview: iv];
iv.center = self.imageView.center;
[iv release];
我在模拟器中看到名为“选择图像”的按钮,但在那里看不到图像。