UIPreviewAction从窥视邮件 [英] UIPreviewAction to Mail From Peek
问题描述
我正在与自己的UIPreviewActions一起在我的应用程序中实现Peek and Pop.我已经设置了我的PreviewView,并且Peek和Pop都可以很好地工作,我的问题是向其中添加UIPreviewActions.当然,您必须将UIPreviewAction方法放在预览控制器中,那么如何获取它然后关闭该视图,并在其父控制器中打开该视图?
I am working on implementing Peek and Pop in my app, along with UIPreviewActions to it. I have my PreviewView all set up, and both Peek and Pop work great, my issue is with adding UIPreviewActions to it. Of course, you have to put the UIPreviewAction method within the preview controller, so how do you get it to then dismiss that view, and open the view within its parent controller?
我在PreviewController中
I have in the PreviewController:
- (NSArray*)previewActionItems {
// setup a list of preview actions
UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"Post to Facebook" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
}];
UIPreviewAction *action2 = [UIPreviewAction actionWithTitle:@"Message" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
}];
UIPreviewAction *action3 = [UIPreviewAction actionWithTitle:@"Email" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
[self displayComposerSheet];
}];
// add them to an arrary
NSArray *actions = @[action1, action2, action3];
// and return them
return actions;
}
displayComposerSheet只是编写电子邮件的标准方法,其中包括用于显示电子邮件的self presentViewController方法.但是,所有这些方法都在PreviewController中,但是从技术上来说,邮件编辑器需要从所有位于其中的TableView启动.我应该怎么做呢?
displayComposerSheet is just a standard method for composing email, that includes the self presentViewController method for displaying it. However, all of this method is within the PreviewController, but the Mail composer technically needs to launch from the TableView where all this is located. How should I go about doing this?
推荐答案
您可以通过Protocol
或NSNotification
来实现.您需要从displayComposerSheet
方法调用控制器(TableView控制器)方法.
You can achieve this by either Protocol
or NSNotification
. You need to call the controller (TableView controller) method from displayComposerSheet
method.
协议示例:
1-在PreviewController中创建协议:
1 - Create protocol in PreviewController:
@protocol PreviewControllerDelegate <NSObject>
- (void) sendEmail;
@end
2-在PreviewController中创建属性为:
2 - Create property in PreviewController as:
@property (nonatomic, weak) id<PreviewControllerDelegate> delegate;
3-从操作方法中调用委托方法:
3 - Call delegate method from action method:
-(void) displayComposerSheet
{
[self.delegate sendEmail];
}
4-在UIViewControllerPreviewingDelegate
方法
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
5-在控制器(TableView Controller)中实现sendEmail
方法,从中可以显示邮件编写器.
5 - Implement sendEmail
method in the controller (TableView Controller) from which you can show the mail composer.
这篇关于UIPreviewAction从窥视邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!