小编Bri*_*lph的帖子

Swift NSUserNotificationCenter doActivateNotification无效

我正在研究一个快速的os x应用程序,我无法理解userNoticiation/didActivateNotification结构.我查看了文档并搜索了SO但仍然卡住了.我们非常感谢您对以下代码的任何指导:

func notify(message: String, callBack: String) {


    println(message)
    println(callBack)
    var notification:NSUserNotification = NSUserNotification()
    notification.title = "New Phone Call"
    notification.informativeText = message
    notification.actionButtonTitle = "Lookup"
    notification.hasActionButton = true
    var center:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()


    center.delegate = self
    center.scheduleNotification(notification)



}
func notify (center: NSUserNotificationCenter, didActivateNotification notification: NSUserNotification){
    center.delegate = self
    println("clicked")  //this does not print
}
Run Code Online (Sandbox Code Playgroud)

通知显示完全符合我的要求.单击我定义的"查找"按钮会在第一次单击时将我的应用程序带到前台,但是我希望处理该操作的代码不会触发.

提前致谢.

macos nsusernotification nsusernotificationcenter swift

7
推荐指数
1
解决办法
1696
查看次数

多页表单提交

我有一个问题,似乎无法通过我的方式.

首先,我有一个由专业人士建立的网站,我们不再与该公司建立工作关系.我现在自己管理这个网站.我有能力,但我绝不是一位经验丰富的网络开发人员.

背景:我们有一个应用程序,它使用呈现给最终用户的多页表单.表单以7个步骤呈现,但它都是从一个php文件完成的,使用(我认为)jquery/javascript来循环执行这些步骤,并验证一些字段.在最后一步中,将提供摘要供用户提交.这很好用.

以下是我认为处理页面循环的相关javascript:

<script>
$(function () {

    window.confirmLeave = true;

    $('.datefield').datepicker();

    var cache = {};                                                                                             // caching inputs for the visited steps

    $("#appForm").bind("step_shown", function(event,data){  

         if(data.isLastStep){                                                                                      // if this is the last step...then
                $("#summaryContainer").empty();                                                                     // empty the container holding the 
                $.each(data.activatedSteps, function(i, id){                                                        // for each of the activated steps...do
                    if(id === "summary") return;                                                                    // if it is the summary page then just return
                    cache[id] = $("#" + id).find(".input");                                                         // else, find the div:s with class="input" and cache them with …
Run Code Online (Sandbox Code Playgroud)

html javascript php forms jquery

4
推荐指数
1
解决办法
2579
查看次数