小编Rag*_*tto的帖子

如何在WatchKit tableview中重新加载数据?

我有一个带有Tableview的iPhone应用程序,其数据来自CoreData.

在此输入图像描述

相同的数据也会显示在观看应用中:

在此输入图像描述

如果我从iPhone应用程序中添加一行:

在此输入图像描述

我在Watch应用程序中重新加载数据:

在此输入图像描述

我看到旧行空了!

在此输入图像描述

如果停止手表应用程序并重新启动它,一切都会正确显示!

在此输入图像描述

这是在Watch应用程序中填充Tableview的代码

-(void)awakeWithContext:(id)context{
    [super awakeWithContext:context];
       [self loadTable];
}

-(void)loadTable{
    NSLog(@"loadTableData");
    NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Data"];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Data"
        inManagedObjectContext:managedObjectContext];
    [fetchRequest setEntity:entity];

    NSSortDescriptor *sortByDate = [[NSSortDescriptor alloc] initWithKey:@"sortedDateAndTime" ascending:NO];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortByDate, nil];
    [fetchRequest setSortDescriptors:sortDescriptors];
    self.watchMArray = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];

  //  [self.watchTableView setRowTypes:self.watchMArray];
    [self.watchTableView setNumberOfRows:self.watchMArray.count withRowType:@"data"];

    for (NSInteger i = 0; i < self.watchMArray.count; i++)
    {
        WatchTableCell *cell = [self.watchTableView rowControllerAtIndex:i];
        NSManagedObject *data = …
Run Code Online (Sandbox Code Playgroud)

iphone core-data ios watchkit wkinterfacetable

19
推荐指数
2
解决办法
9645
查看次数

在Safari中获取所选文本并在操作扩展中使用它

我正在为Safari进行动作扩展,我需要在扩展中获取所选文本.

通常在iOS中,我使用此代码在webview中获取所选文本

selectedText.text = [WebView stringByEvaluatingJavaScriptFromString: @ "window.getSelection (). toString ()"];
Run Code Online (Sandbox Code Playgroud)

但在扩展内部我不知道该怎么办!

为了完整性,它应该是IU的扩展,我只是打开NSExtensionActivationSupportsWebURLWithMaxCount以在Safari中提供扩展.

提前致谢

xcode action mobile-safari ios8 ios-app-extension

9
推荐指数
1
解决办法
3014
查看次数

'WKInterfaceController'没有可见的@interface声明选择器'initWithContext:'

从上一个Xcode测试版开始,我在我的所有项目和所有示例代码中都出现了错误,也像在像Lister app这样的Apple示例代码中出错!

'WKInterfaceController'没有可见的@interface声明选择器'initWithContext:'

在此输入图像描述

问题出在哪儿 ?谢谢

ios xcode6 watchkit

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

两件式图像并发症

我想显示一个多色复杂功能图标,类似于默认的计时器应用程序图标:

在此处输入图片说明

这是我用多色显示图标的代码:

CLKComplicationTemplateModularSmallStackImage* template=[[CLKComplicationTemplateModularSmallStackImage alloc]init];

template.line1ImageProvider=[CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"Complication/Modular"] 
    twoPieceImageBackground:[UIImage imageNamed:@"ComplicationForeground/Modular"] 
    twoPieceImageForeground:[UIImage imageNamed:@"ComplicationBackgroud/Modular"]];

entry = [CLKComplicationTimelineEntry entryWithDate:[NSDate date]
                                           complicationTemplate:template];
Run Code Online (Sandbox Code Playgroud)

两幅图像都有清晰的背景。如何使用 whiteColor 为中心图像着色,并使用另一种颜色为外部图像着色?

xcode objective-c watchkit watchos-2 apple-watch-complication

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

外观更改时更新 Widget

light我需要知道你们中是否有人知道 SwiftUI 中的一个系统,当外观从模式切换到模式时更新 Widget,dark反之亦然。

我可以更改文本和图像,但我使用一种方法来显示地图的屏幕截图,并且每次外观发生变化时我都应该运行它以获得正确的地图颜色。

swift widgetkit swiftui ios14

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