【问题标题】:Getting UiImage from CgContextRef and pass it to another ViewController从 CgContextRef 获取 UiImage 并将其传递给另一个 ViewController
【发布时间】:2012-07-18 11:59:43
【问题描述】:

我想从 CGContextRef 中取出 UIImage,并在不同的 UIViewController 中的 UIImageView 上显示它

为此,我写了这段代码,我正在写这段代码,当我关闭我的绘图视图时,因为我已经将我的绘图视图作为 UIViewController 的子视图

//mydrawingView.m

- (void)closeButtonClicked
{
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO,0.0);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    m_curImage = UIGraphicsGetImageFromCurrentImageContext();  
    UIGraphicsEndImageContext();


    ViewController *table = [[ViewController alloc] init];
    [table setImage:m_curImage]; 
    [table viewDidLoad];
}

///myViewController.h

@interface ViewController : UIViewController
{   
    IBOutlet UIImageView *m_imageView;
    UIImage *image;

}

@property(nonatomic, strong) UIImage *image;

///myViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];    

    m_imageView.image = image; 

    NSLog(@"%@", m_imageView.image);
}

但我无法在 UIImageview 上显示此图像,

问候 兰吉特

【问题讨论】:

  • 朋友您好,有什么建议吗?

标签: ios uiimageview uiimage core-graphics quartz-2d


【解决方案1】:

我已经整理好了这个问题的答案,要从画布中取出图像,上面的代码适用并显示在anotherViewController的imageView上,我们必须实现委托协议方法。

问候 兰吉特

【讨论】:

    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多