问题标签 [ios10-today-widget]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1750 浏览

ios - 今日扩展在有限的设备上“无法加载”

我有一个带有 Today Extension 的 iOS 应用程序。我们现在正在测试(TestFlight),并且已经在大约十台设备上进行了测试。关联的小部件在除其中一台设备之外的所有设备上都可以正常显示。在一台设备上,小部件会显示可怕的“无法加载”消息。我们尝试过重启设备、删除/重新安装应用程序等。

查看设备日志,我看到这是第一个麻烦的参考:

扩展程序的代码没有尝试打开主机应用程序,所以这个错误让我很困惑。也许这指的是内部(iOS)帮助应用程序?

第一行中的奇数转义字符在日志中。在这些行之后,它再次尝试,可能再试两次,然后失败。最终我看到Can't request remote view controller that is blacklisted并且设备在重新启动之前不会重试:

我没有看到扩展代码本身的任何日志记录,也没有任何迹象表明它实际上正在启动。

有问题的设备是 iPhone 7 Plus,运行 iOS 10.3.2 的公共版本。该小部件在所有其他设备上运行良好,其中许多设备也是 10.3.2。其他都不是 iPhone 7 Plus。该小部件在 iPhone 7 Plus 模拟器中运行良好。

同一台设备可以正常运行 App Store 版本的小部件,尽管该版本是针对 iOS 9 和 Xcode 7 构建的。新版本使用 10.3 作为其基本 SDK,使用 Xcode 8.3.3。

有什么想法吗?

0 投票
1 回答
452 浏览

ios - Swift iOS 11 Beta Today 小部件 infoPlist.Strings 未本地化

在我开始使用 iOS 11 beta 之前,我一直在我的 Swift 程序中使用 Today Widget 并且没有遇到任何问题。从那时起,Bundle Display Name它就没有本地化。在我的Info.Plist我有:

在我的InfoPlist.Strings文件中,我有

如果我在 iOS 11 beta 之前的任何东西上显示小部件,则字符串会正确本地化,但是当我使用 iOS 11 beta 设备时,NSLocalizedString(CFBundleDisplayName, nil)会显示字符串。

有谁知道可能导致此问题的 iOS 11 测试版或错误的更改?

0 投票
1 回答
270 浏览

ios - 打开 TableView 并选择行

我的应用程序有一个今天的小部件,它有一个UITableView. 每当用户点击一行时,我想打开主 iOS 应用程序,UIViewController使用UITableView. 导航到,然后选择对应的单元格。

我知道打开应用程序,我会做这样的事情:

并选择行,我会这样做:

不过,我将如何从 Today Widget 一起完成这一切?

0 投票
0 回答
43 浏览

ios - Today Extension 的核心数据请求返回 0 个结果?

我正在开发一个简单的应用程序,并希望包含来自 Today Widget 的一些核心数据功能。然而,这给我带来了一些麻烦,我不确定我错过了什么。

这是我所做的:

  1. 我已将小部件目标添加到核心数据模型
  2. 没有添加我的实体子类。这会打开一堆带有大量 sharedApplication 引用的蠕虫。我不需要在小部件中做太多事情,所以我认为只使用 NSManagedObject 实例会容易得多。
  3. 在小部件的 viewDidLoad 中,我创建了一个持久容器:

    /li>

到目前为止一切顺利,没有返回错误。

但是,当我调用时没有返回结果:

实体名称和谓词似乎没有什么区别。不返回请求错误。相同的请求在应用程序中正常工作。

看起来我可能正在启动一个空容器而不是抓住正确的容器?我敢肯定这是一件简单的事情,但我不知所措。任何帮助表示赞赏。

0 投票
1 回答
813 浏览

swift - 将数据从 Core Data 加载到 Today Widget

我有使用 Swift 编写的 iOS 应用程序,可与 Core Data 一起使用。不,我想获取 Core Data 中存在的最后一条记录并将其呈现在 Today Widget Extension 中。

  1. 我在我的项目中添加了新的小部件目标
  2. 在我的coredata.xcdatamodeld中,我还检查了扩展的目标成员资格
  3. 对于两个目标(应用程序和扩展程序),我添加并启用了专门创建的应用程序组group.myapp.sharingForTodayExtension
  4. 这是我来自 TodayViewController 的代码

    /li>

这是 PersistentContainer 的特殊类

问题是它显示记录数 = 0

0 投票
1 回答
978 浏览

ios - Today Widget uses more memory each time it refreshes, then eventually crashes

I’m working on a Today Widget, and running into memory issues.

When I run the widget and monitor memory usage Xcode, the widget uses about 15MB when it first starts up. Then, when I swipe away from the widget screen and back, it goes up to about 16MB.

Every time I swipe away and back it memory usage goes up by about 0.5–1.5MB. As I do it more I get memory warnings (didReceiveMemoryWarning() is called) and eventually, with more swiping, the widget crashes.

All these symptoms are happening while testing on an iPhone X. On the simulator, the widget starts off using around 50 megabytes, which seems kind of odd, but it has the same behavior where memory usage goes up each time I swipe away and swipe back.

I've tried analyzing this with Instruments, but I'm only able to get Instruments to show what happens at the beginning (when I first launch the Widget) and it doesn't keep running as I swipe away and back.

Through the process of elimination (commenting out the actual functionality of my widget) the issue still happens when just the UI code remains. This makes me think it’s a problem with my UI approach.

I’ve built Today Widgets in the past, but always used Interface Builder. This time I decided to build the interface programmatically instead. I don’t see this same behavior of increasing memory usage with each refresh when I look at other Today Widgets I’ve built with Interface Builder.

First, I set up all my UI elements as private lazy variables, like this:

Then, in viewDidLoad(), I add my views to the TodayViewController's view with some constraints, like this:

Since I'm new to building UI programmatically, is there anything with this approach that seems blatantly incorrect and looks like it could cause a memory leak?

I've even tried commenting out all of my code and running it with a basic blank UIViewController, where the view lifecycle functions don't even do anything, and I still experience the memory leak. That makes me think there's something I should be doing when I build the interface programmatically that I'm not doing.

It seems like something's not being released and being duplicated in memory each time the Today Widget appears. I'd appreciate any suggestions for how I could find what's not being released and force the system to release it. Thanks!


SOLVED

Thanks to the troubleshooting tip provided by Christopher Pickslay, I was able to track down the issue. It turned out to be my fault. To troubleshoot a previous unrelated issue, I had turned on the Zombie Objects in the scheme, and I still had it enabled. Once I turned that off the issue went away. This is the setting I'm talking about: Zombie Objects checkbox in Xcode

0 投票
1 回答
51 浏览

swift - 如何从表格中删除标题和详细信息占位符标签及其行?

在通过网络(和 Xcode)进行大量搜索之后,我还没有找到任何方法来从今天小部件的表格视图中删除标题和详细信息占位符标签及其包含的行。见下图:

Today Widget 界面生成器截图

0 投票
1 回答
1670 浏览

ios - 为什么 Today Widget 在 iOS 14 上显示“无法加载”且无法调试?

在 iOS 14 上运行我的 iOS 12+ 应用程序时,(长期存在的)今日小部件不再工作。而不是只显示小部件内容Unable to load

相同的代码在 iOS 13 及更低版本上运行没有任何问题。

注意:这与 iOS 14 引入的新主屏幕小部件无关。它们工作正常这是关于今天的小部件。

Unable to load我发现了几个关于这个问题的现有线程和其他资源。但是,它们都较旧,并且与 iOS 14 无关。在几乎所有情况下,问题都是小部件崩溃,因此无法加载。

我尝试通过直接从 Xcode 运行它来调试小部件扩展:选择 Widget 目标而不是 App 目标并运行项目。这在 iOS 13 及更低版本上运行良好。小部件变得可见并按预期工作。另外我可以使用断点等来检查是否有任何问题。

然而,在 iOS 14 上,当我开始调试时没有任何反应,希望 Xcode 显示Running com.apple.springboard on iPhone XYZ. 当我手动切换到今天的屏幕时,小部件Unable to load再次显示。

由于调试不起作用,我添加了一种将消息记录到应用程序组文件夹中的文件的方法。虽然这在 iOS 13 及更低版本上也可以正常工作,但在 iOS 14 上没有任何作用。

我正在使用 Xcode 12.1,据我所知,iOS 14 和 14.1 都受到了影响。

似乎 Widget 根本无法在 iOS 14 上运行。

知道问题可能是什么吗?知道如何在不调试或记录的情况下找到问题的根源吗?