从另一个视图控制器创建 UIImage
当我想要触发创建的操作是另一个视图控制器中的按钮时,如何在一个视图控制器中创建 UIImage?
所以我想在视图控制器中有一个按钮,当按下该按钮时,会关闭该视图并在另一个视图中创建一个 UIImage。
这是怎么做到的?
谢谢
How does one create a UIImage within one viewcontroller, when the action which I want to trigger the creation is a button in another viewcontroller?
So I would like to have a button in a viewcontroller, which when pressed, dismisses this view and create a UIImage in the other view.
How is this done?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在按钮保持 VC 中保留对图像保持 VC 的引用。实例变量(例如 otherViewController)似乎很合适。
在第一个 VC 中,您实现了创建新 UIImage 的方法。
在第二个 VC 中,您创建一个在点击按钮时调用的方法。在此方法中,您访问第一个 VC 并调用刚刚编写的方法。
You can keep a reference to the image-holding VC in the button-holding VC. An instance variable (e.g. otherViewController) seems suitable.
In the first VC, you implement a method that creates the new UIImage.
In the second VC, you create a method that is called when the button is tapped. In this method, you access the first VC and call the just written method.
你需要更具体。你如何展示下一个视图控制器?您是否正在启动它然后推送它?
如果您在该视图控制器中,则可以拥有一个 BOOL 属性 (
BOOL makeImage;
)。当您创建要推送的视图时,请执行以下操作:然后在
TheNextViewController
的viewDidLoad
中:您可能必须设置其他变量,例如
NSString *imageName;
如果您希望按钮显示特定图像,请在...setMakeImage:YES]
时设置它们。You need to be more specific. How are you showing the next view controller? Are you init'ing it and then pushing it?
If you are then in that viewcontroller you could have a BOOL property (
BOOL makeImage;
). When you create the view to push do this:then in
viewDidLoad
ofTheNextViewController
:You might have to set other variables up like
NSString *imageName;
and set those when you...setMakeImage:YES]
if you want the button to show a specific image.