小编Pra*_*ias的帖子

在watchOS2中的Watch应用程序和iOS应用程序之间共享数据

我使用以下命令向iOS应用程序发送字典:

- (void)sendMessage:(NSDictionary<NSString *, id> *)message 
  replyHandler:(nullable void (^)(NSDictionary<NSString *, id> *replyMessage))replyHandler 
  errorHandler:(nullable void (^)(NSError *error))errorHandler;
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误.我想知道我们的父应用程序如何在watchOS2中处理此请求.

在watchOS1中,我曾经openParentApplication从父应用程序获取数据,并且Appdelegate有一个handleWatchKitExtensionRequest处理该请求的数据.我们如何在watchOS2中处理这个问题?

我的界面控制器:

- (void)awakeWithContext:(id)context 
{
   [super awakeWithContext:context];
   if([WCSession isSupported])
   {
     self.watchSession = [WCSession defaultSession];
     self.watchSession.delegate = self;
     [self.watchSession activateSession];
   }
   [self sendRequestWithActionType:@"InitialView"];
}

-(void)sendRequestWithActionType:(NSString *)action
{
    NSDictionary *requst = @{@"request":action};
    [[WCSession defaultSession] sendMessage:requst
                           replyHandler:^(NSDictionary *replyHandler) {
                               [self setTextForLabelWithData:[replyHandler valueForKey:@"response"]];
                           }
                           errorHandler:^(NSError *error) {
                               NSLog(@"");
                           }
 ];
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios watchkit watchos-2

7
推荐指数
1
解决办法
2114
查看次数

在whatsapp中分享多个视频

我想在whatsapp中分享多个视频.我是使用UIActivityViewController进行的.首先我将视频存储在iPhone上并发送URL(NSURL).如果我发送一个URL它可以工作但如果我发送多个URL它不起作用.UIActivityViewController做不显示whatsapp图标.

NSURL *urlOne = url;
NSURL *urlTwo = url;

NSArray *items  = [NSArray arrayWithObjects:urlOne,urlTwo,nil];

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
NSArray *excludedActivities = @[UIActivityTypePostToWeibo,UIActivityTypeMail,
                                UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
                                UIActivityTypeAssignToContact,UIActivityTypePostToFlickr,
                                UIActivityTypePostToVimeo,UIActivityTypeAirDrop, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;
[self presentViewController:controller animated:YES completion:nil]; 
Run Code Online (Sandbox Code Playgroud)

我想知道,whatsapp支持多个视频共享,如果它支持如何做到这一点?

objective-c ios whatsapp uiactivityviewcontroller

6
推荐指数
1
解决办法
849
查看次数

设置AVPlayerItem时UITableView滞后

AVPlayer在表view.table视图中使用时设置滞后AVPlayerItem。下面是cellForRowAtIndexPath方法代码。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *tableIdentifier = @"tableIdentifier";
     CustomTableCell *cell = [self.videoTableView dequeueReusableCellWithIdentifier:tableIdentifier];
     if (cell == nil) {
         cell = [[[NSBundle mainBundle]loadNibNamed:@"VideoCell" owner:self                   options:nil]objectAtIndex:0];
    }
     dispatch_queue_t queue =  dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
     dispatch_async(queue, ^{
         AVAsset *avAssert = [AVAsset assetWithURL:[NSURL URLWithString:@"url"]];
         cell.playerItem =[[AVPlayerItem alloc]initWithAsset:avAssert];
         dispatch_sync(dispatch_get_main_queue(), ^{
             if (!cell.avPlayer) {
                 cell.avPlayer = [AVPlayer playerWithPlayerItem:cell.playerItem];
            }else{
                [cell.avPlayer replaceCurrentItemWithPlayerItem:cell.playerItem];
    }
    if (!cell.avPlayerLayer) {
        cell.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:cell.avPlayer];
        cell.avPlayerLayer.frame = cell.videoPlayerView.layer.bounds;
        cell.avPlayerLayer.videoGravity = AVLayerVideoGravityResize;
        [cell.videoPlayerView.layer …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios avplayer avplayeritem

5
推荐指数
0
解决办法
605
查看次数