在自定义 WatchKit 通知上同时显示 alertTitle 和 AlertBody

Display both alertTitle and AlertBody on a custom WatchKit notification

当我将带有 alertTitle 和 alertBody 的本地通知发送到 Apple Watch 时,这两个字段都会显示在长看通知中。但是,当我使用静态通知控制器界面场景对其进行自定义时,XCode 中的默认故事板只有一个字段,其中填充了 alertBody(而不是 alertTitle)。

如何配置 Storyboard 以包含这两个字段? 我可以向 Storyboard 添加新标签,但我不知道如何 link alertTitle 字段的新标签。

这是我用来显示通知的代码:

var localNotification = UILocalNotification()
localNotification.alertTitle = "Silver Maple"
localNotification.alertBody = "Silver Maple (1658) Acer saccharinum"
UIApplication.sharedApplication().presentLocalNotificationNow(localNotification)

这是没有自定义界面的样子:

这是我的故事板,显示了仅显示 alertBody 的自定义界面:

Apple Watch Programming Guide: Managing a Custom Long-Look Interface 中(在 "Configuring a Static Notification Interface," 部分下它说:

The interface’s notificationAlertLabel outlet must be connected to a label. The label’s contents are set to the notification’s alert message. The text for all other labels does not change.

遗憾的是,我认为无法将您的自定义标签 link 添加到 alertTitle 字段。如果您查看 Interface Builder 中的静态接口控制器,您会注意到它没有以任何方式 linked 到您的自定义 WKUserNotificationInterfaceController class。因此,实际上无法手动连接任何插座。