标签: ios8-today-widget

当没有什么可显示时,如何隐藏iOS 8 Today Widget?

我正在使用iOS8的今日小部件来显示与当天相关的信息.问题是如果没有要显示的相关消息,我根本不想显示小部件/部分.

我知道它必须是可能的,因为BA应用程序会这样做(它只在有航班时显示小部件,其余时间根本不可见).我只是想办法实现这种行为.

有谁知道如何做到这一点?

objective-c ios-app-extension ios8-extension ios8-today-widget

5
推荐指数
1
解决办法
3637
查看次数

从通知小组件中查找设备是否已锁定

我想知道当我加载Notification/Today小部件时设备是否被锁定,所以我可以适当地显示小部件.(这是财务方面的,我们不想在锁定的手机上显示余额)

在具有TouchID的设备上,我可以尝试访问Keychain,如果我得到的话

errSecInteractionNotAllowed

回来了,它被锁定了.都好.这在没有touchID(但带有PIN)的设备上不起作用.我找到了一些建议使用的东西

[[UIApplication sharedApplication] protectedDataAvailable]

但是我没有[UIApplication sharedApplication]小部件.

任何想法在哪里以及如何做到这一点?我只需要一个是/否:设备被锁定了.

谢谢

[更新:这是我的代码]

获取文件名:

+ (NSString *)lockedDeviceFilename {
    NSURL *directoryUrl = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:USER_DEFAULTS_GROUP_NAME];
   return [directoryUrl.path stringByAppendingPathComponent:@"security.dummy"];
}
Run Code Online (Sandbox Code Playgroud)

编写/创建文件(在应用程序中,而不是扩展名:

NSError *error = nil;

NSString *documentPath = [FOOStorageGatekeeper lockedDeviceFilename];

[[NSFileManager defaultManager] removeItemAtPath:documentPath error:&error];

BOOL created = [[NSFileManager defaultManager] createFileAtPath:documentPath
                                                       contents:[@"super secret file contents. we only care about the permissions" dataUsingEncoding:NSUTF8StringEncoding]
                                                     attributes:@{NSFileProtectionKey : NSFileProtectionComplete}];
Run Code Online (Sandbox Code Playgroud)

读:

 BOOL isReadable = [[NSFileManager defaultManager] fileExistsAtPath:[FOOStorageGatekeeper lockedDeviceFilename]];

  NSLog(@"isReadable? %@", isReadable ? @"YES" …
Run Code Online (Sandbox Code Playgroud)

objective-c ios ios8-today-widget today-extension

5
推荐指数
1
解决办法
2046
查看次数

在今天的扩展中使用 AppDelegate

我正在尝试为我的应用程序构建一个今天的扩展。

我正在使用CoreDataandNSFetchedResultsController并收到以下错误:

使用未声明的类型“AppDelegate”

在这行代码中:

var appDel: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate. 
Run Code Online (Sandbox Code Playgroud)

有人知道如何解决这个错误/在今天的扩展中使用 AppDelegate 并愿意帮助我吗?

ios appdelegate swift ios8-today-widget today-extension

5
推荐指数
1
解决办法
3681
查看次数

刷新今日扩展视图

我为我的iOS App创建了今天的扩展.我的应用程序在后台获取新数据并将其保存到应用程序组中的共享数据库中.

当执行主应用程序的后台提取时,我如何制作(如果可能的话)扩展以更新它的视图?如果不可能,我怎么能做出相同的东西(比如定期更新扩展以检查共享数据库中的新数据).

xcode cocoa-touch ios ios8 ios8-today-widget

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

今天的iOS8视图小部件没有显示UITableViewController

我刚开始学习如何在iOS8上创建今天的视图小部件.我为扩展创建了一个新目标.下一步我删除了默认viewcontroller和类,并创建了一个新的UITableViewController及其相应的方法.我实现了以下内容:

#import "TableViewController.h"
#import <NotificationCenter/NotificationCenter.h>

   @interface TableViewController () <NCWidgetProviding>
{
    NSArray *nameArray;
}
@end

@implementation TableViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    nameArray = [[NSArray alloc]initWithObjects:@"joey",@"jack",@"jill", nil];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {


    completionHandler(NCUpdateResultNewData);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    cell.textLabel.text = …
Run Code Online (Sandbox Code Playgroud)

ios ios8-today-widget

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

如何从Today Widget打开特定的View Controller?

我正在创建一个简单的今日小部件,其中包含一个按钮,此按钮应该 - 按下时 - 在我相应的应用程序中打开一个特定的视图控制器.

我想到的唯一解决方案是创建一个只能打开初始视图控制器的URL类型(至少据我所知).

下面是我目前在UIButton操作中使用的代码:

   var url = NSURL(string: "_my_url_://")
    extensionContext?.openURL(url!, completionHandler: nil)
Run Code Online (Sandbox Code Playgroud)

ios swift ios8-today-widget

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

iOS App Today Extension未上传到物理设备

我正在为我的应用http://budgt.ch创建一个今天的小部件,因为一些用户要求快速访问关键功能.

(初步)扩展在iOS模拟器上正常工作,安装如下:

1)安装最新的容器应用2)使用'today'作为容器安装扩展

但是:我似乎无法在物理设备上显示扩展(我目前正在使用iPhone 6进行测试).

  • xcode说:建立成功
  • 扩展未在今日视图中显示

什么想法可能是错的?

xcode objective-c ios ios8-today-widget ios-extensions

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

我可以在我的主机应用中阅读我的应用扩展程序的info.plist吗?

我已经构建了一个今天的小部件,我想显示我的主机应用程序中关于屏幕的版本.有没有办法做到这一点?

我试着更换[NSBundle mainBundle]bundleWithIdentifier,但失败了.那么,有没有办法infoDictionary从他的扩展包中获取,或者我是在浪费时间?

ios ios8-today-widget today-extension

3
推荐指数
1
解决办法
748
查看次数

暂时禁用今天的扩展程序

我在我的应用程序中有一个今天的扩展,我想要退出我提交到App Store的下一个版本,但保留在项目中以便在更高版本中提交.

我已经尝试将其从容器应用程序目标的目标依赖项中删除,但它仍然显示出来.

我怎样才能做到这一点?

objective-c ios ios8-today-widget

3
推荐指数
1
解决办法
1179
查看次数

如何在通知中心频繁更新今天的小部件?

我发现通知中心窗口小部件不经常重新加载。因此,将显示过期数据。每次打开“今日”视图时,我都无法找到一种使小部件刷新的方法。我看过诸如NBA Gametime之类的应用程序,每次我下拉查看小部件时都能够更新。

如何在我的应用程序中获得此功能?

objective-c ios ios8-today-widget

2
推荐指数
1
解决办法
3085
查看次数