简体   繁体   English

在SDK中实现自定义取消按钮

[英]Implement custom Cancel Button in a SDK

I want to implement payment functionality with paysbuy SDK....The problem is it doesnot have any cancel option on it so that user can cancel the operation of close after the payment has been successful. 我想用paysbuy SDK实现支付功能....问题是它没有任何cancel选项,以便用户可以在付款成功后取消关闭操作。

By default SDK provides a method that opens the default WebView that covers the whole part of the screen..And there is no any cancel option.. 默认情况下,SDK提供了一种方法,可以打开覆盖屏幕整个部分的默认WebView并且没有任何cancel选项。

I just want to add a cancel button by load the payment on the specific view ..or viewcontroller ..I tried using in container view..to load the view inside the container view and a cancel button outside the container view ,but when i try this process,it shows by default in Full Screen WebView .Also tried creating a PopUP but didnot succeed 我只是想添加一个cancel由负载按钮支付的具体view ..或viewcontroller使用..我试过container view..to加载内部的视图container视图和cancel的按钮外container的观点,但我当尝试这个过程,它默认显示在全屏WebView 。也尝试创建一个PopUP但没有成功

So, how can i load the webview of SDK on a specific portion of my view so that i can put a Cancel button?? 那么,我如何在我的view的特定部分加载SDKwebview ,以便我可以放置Cancel按钮?

This is the method that the sdk provides to start the service 这是sdk提供的启动服务的方法

- (void) callServiceWithCurrentView :(UIViewController *) currentViewController
                             invoice:(NSString *)invoice
                                item:(NSString *)item
                              amount:(NSString *)amount
                       paypal_amount:(NSString *)paypal_amount
                      transferMethod:(NSString *)transferMethod
                    customerLanguage:(NSString *)customerLanguage
                       operator_name:(NSString *)operator_name
                      operator_email:(NSString *)operator_email
                     operator_mobile:(NSString *)operator_mobile
                    operator_address:(NSString *)operator_address
                     operator_detail:(NSString *)operator_detail;

Here we can see the callServiceWithCurrentView method shows the target as currentviewcontroller so i think it loads by default in full screen mode on the viewcontroller .... 在这里我们可以看到callServiceWithCurrentView方法将目标显示为currentviewcontroller所以我认为它在viewcontroller上默认以full screen模式加载....

Here is how i implemented in swift 这是我在swift中实现的方式

   paysBuy?.callServiceWithCurrentView(self, invoice: "343434343", item: "App Fee", amount: "10", paypal_amount: "1", transferMethod: "1", customerLanguage: "E", operator_name: "PAYSBUY", operator_email: "abc@paysbuy.com", operator_mobile: "0888888888", operator_address: "PAYSBUY.COM", operator_detail: "PAYMENT")

And a delegate method that handles the response in case of success or failutre 以及在成功或失败时处理响应的委托方法

extension PaysBuyHelper:PaysbuySDKDelegate{
    func responseWithResult(result: String!, andInvoice invoice: String!) {

        //here is the response of the payement

        println(result)
        println(invoice)

        if result == "00" {

            println("transaction complete and below is the invoice number")
            println(invoice)

        }else if result == "90"{

            println("transaction incomplete information")

        }

    }

}

Here is the work that i have done.... https://drive.google.com/file/d/0Bzk4QVQhnqKmVno5NGdPUV9ITkE/view?usp=sharing 这是我做过的工作.... https://drive.google.com/file/d/0Bzk4QVQhnqKmVno5NGdPUV9ITkE/view?usp=sharing

Modal controllers are presented within the frame context of the controller which is deemed to define the presentation context. 模态控制器在控制器的帧上下文中呈现,其被认为定义了呈现上下文。

An option you have is to make the controller which calls callServiceWithCurrentView define the context for any modal presentation which can then be used to restrict the area on screen that is used. 您拥有的一个选项是使调用callServiceWithCurrentView的控制器为任何模态表示定义上下文,然后可以使用该上下文来限制所使用的屏幕上的区域。

You do this in XCode by clicking on your presenting controller and selecting the Defines Context checkbox. 您可以通过单击演示控制器并选择“定义上下文”复选框在XCode中执行此操作。 In code you can set the definesPresentationContext to TRUE. 在代码中,您可以将definesPresentationContext设置为TRUE。

For this to be of use to you, you need the frame for the presenting controller to not be full screen. 为了对您有用,您需要显示控制器的框架不是全屏。 The ideal situation would be that this is a controller inside a UINavigationController. 理想情况是这是UINavigationController中的控制器。

Options: 选项:

1) Your presenting controller is inside a navigation controller with a navigation bar. 1)您的演示控制器位于带导航栏的导航控制器内。 Effectively it is a child controller. 实际上它是一个儿童控制器。 The screen footprint it uses is dependent on whether it goes under the top and bottom bars. 它使用的屏幕占用面积取决于它是否位于顶部和底部条形下方。 a) Set your controller so that content does not go under the top bars. a)设置控制器,使内容不在顶部栏下面。 This effectively makes the frame under the navigation bar. 这有效地使框架位于导航栏下方。 b) When you call callServiceWithCurrentView , add a cancel button on the navigation bar. b)当您调用callServiceWithCurrentView ,在导航栏上添加一个取消按钮。 c) If you set the controller to define the presentation context properly, then the UIWebView should show up under the navigation bar and you can see your new cancel button. c)如果您将控制器设置为正确定义演示文稿上下文,则UIWebView应显示在导航栏下方,您可以看到新的取消按钮。

2) If not in a navigation controller, then rather than calling the method directly, add a child controller inside a sub view above which you put your cancel button. 2)如果不在导航控制器中,则不是直接调用该方法,而是在子视图中添加子控制器,在该子视图上放置取消按钮。 Have this child controller do the call callServiceWithCurrentView . 让这个子控制器执行call callServiceWithCurrentView Following the same mechanism, make this child controller define the context. 遵循相同的机制,使这个子控制器定义上下文。 Any modal UIWebView should then only cover the area of the child controller. 然后,任何模态UIWebView都应该只覆盖子控制器的区域。

Hope this gives you some options. 希望这能为您提供一些选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM