Calendar “从UI打开日历”按钮

Calendar “从UI打开日历”按钮,calendar,uibutton,shortcut,Calendar,Uibutton,Shortcut,我做了很多次搜索,想找到一种从我应用程序中的UIButton打开本机日历应用程序的方法。 我找不到从UIButton做这件事的方法 我发现的唯一方法是在网络视图中输入日期并激活事件检测 有人能通过下面的方法找到它的方法吗 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"calendrier"]]; 我找到了一个办法。 这并不是使用UIButton的真正意义,但它是有效的 将带有图标的图像放在uiview上 在此

我做了很多次搜索,想找到一种从我应用程序中的UIButton打开本机日历应用程序的方法。 我找不到从UIButton做这件事的方法

我发现的唯一方法是在网络视图中输入日期并激活事件检测

有人能通过下面的方法找到它的方法吗

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"calendrier"]];
我找到了一个办法。 这并不是使用UIButton的真正意义,但它是有效的

  • 将带有图标的图像放在uiview上
  • 在此图标上放置一个webview(称为webViewBtn)
  • 密码 NSString*path=[[NSBundle mainBundle]pathForResource:@“议程按钮”的类型:@“html”]; NSURL*baseURL=[NSURL fileURLWithPath:path]; NSString*fileText=[NSString stringWithContentsOfFile:路径编码:NSUTF8StringEncoding错误:nil]; NSMutableString*agendaButton=[[NSMutableString alloc]initWithFormat:fileText,Date2OpenCalendar]; [webViewBtn loadHTMLString:agendaButton baseURL:baseURL]; 并在项目中放置一个名为“agenda button.HTML”的HTML文件,其中包含以下行:

    <html>
    <head>
        <style type="text/css">
            <!--
            html,body,p,a{
                display: block;
                width: 60px;
                height: 40px;
                /*background: url(btn_agenda.png) top left no-repeat;*/
                text-indent: -9999px;
                                font-size: 1px;
                }
                -->
            </style>
        </head>
        <body>%@</body>
    <html>
    
    
    %@
    
    您将看到一个包含以下选项的操作表:“创建事件”、“在日历中显示”、“复制”

    PS:允许在webview中检测事件

    <html>
    <head>
        <style type="text/css">
            <!--
            html,body,p,a{
                display: block;
                width: 60px;
                height: 40px;
                /*background: url(btn_agenda.png) top left no-repeat;*/
                text-indent: -9999px;
                                font-size: 1px;
                }
                -->
            </style>
        </head>
        <body>%@</body>
    <html>