【问题标题】:How to pass the Uiimage when popview controller in iphoneiphone中弹出视图控制器时如何传递Uiimage
【发布时间】:2013-02-01 09:28:52
【问题描述】:

在 iPhone 中使用 popview 控制器时,任何人都有将图像从一个视图传递到另一个视图的精确解决方案。

请给我一些关于这个问题的指导。 谢谢。

【问题讨论】:

  • 您可以创建协议并传递图像。另一种方法是将图像存储在 appdelegate 或任何全局图像对象中。
  • 您可以使用 ivar 将变量从一个类传递到另一个类。
  • 发布您的代码,因为现在我们必须猜测您在做什么。通过您的代码,我们会指出您的问题所在。
  • 你试过什么? .如果您发布一些代码,那么我们可以帮助您。 no1 将为您提供您想要的完整代码。
  • 这里我想传递裁剪后的图像。在第一个视图中 -(void)btn_Press {croppedViewcontroller* myCropImg = [[croppedViewcontrolleralloc]initWithNibName:@"croppedViewcontroller" bundle:nil]; [myCropImg setScrollView:self.img.image]; [self.navigationController pushViewController:myCropImg 动画:YES]; } ////这里我在做cropping.CGImageRef imageRef=CGImageCreateWithImageInRect([imageview.image CGImage],cropRects); resultImage = [UIImage imageWithCGImage:imageRef]; CGImageRelease(imageRef); targetview.imageview.image = self.image; [self.navigationController popViewControllerAnimated:YES];

标签: iphone ios objective-c popviewcontroller


【解决方案1】:

使用协议委托方法使用图像,或者将您的图像分配给另一个控制器图像对象并使用它。

【讨论】:

  • 我已经为图像设置了代表,但没有得到解决方案。
  • 您是否能够获取传递给应用委托的对象的引用?
  • 嗯,你可以使用参考图像。这就是你应该发送 ryt 的传递对象。
【解决方案2】:

假设你的 imageview 是existingImageView;

.h

@interface SecondController : UIViewController

@property (retain, nonatomic) UIImageView *previousImageView;

.m

@interface SecondController ()

@结束

@implementation SecondController @synthasize previousImageView;

现在在 firstController 中导航时使用它,

SecondController *second = [[SecondController alloc] init];
[self.navigationController pushViewController:second animated:YES];
[second setPreviousImageView:existingImageView];
[photoController release];

裁剪图像后,它会反映到现有的ImageView。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-08
    • 2017-04-22
    • 2012-11-13
    • 1970-01-01
    • 2013-01-16
    • 1970-01-01
    • 2010-10-14
    • 2016-11-28
    相关资源
    最近更新 更多