小编Kep*_*tos的帖子

当关闭蓝牙时,didExitRegion没有被解雇

我正在构建一个简单的ios应用程序IBeacon,我正在监视一个区域,但我对进入和退出事件有一些问题.

如果我进入一个区域,回调didEnterRegion被触发,但在该区域内,关闭蓝牙不会触发didExitRegion回调.这是预期的行为吗?

这是一个问题,因为我必须能够检测用户何时退出该区域.任何的想法?

谢谢

bluetooth objective-c core-location ios ibeacon

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

如何在导航控制器内的storyboard中从appdelegate推送viewcontroller

我在我的项目中使用SWRevealViewController,我想在应用程序收到通知时打开一个特定的控制器.我尝试了很多解决方案,但没有任何效果.

我通过使用故事板来关注这个http://www.appcoda.com/ios-programming-sidebar-navigation-menu/.我的故事板设计如下:

故事板

当应用程序收到通知时,我想在其导航控制器中加载照片视图控制器.我尝试使用AppDelegate中的以下代码:

UIStoryboard *st = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
    photoViewController *descController = (PhotoViewController*)[st instantiateViewControllerWithIdentifier: @"photoView"];
    UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:descController];
    SidebarTableViewController *rearViewController = (SidebarTableViewController*)[st instantiateViewControllerWithIdentifier: @"menuController"];

    SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]  init];

    mainRevealController.rearViewController = rearViewController;
    mainRevealController.frontViewController= frontNavigationController;
    self.window.rootViewController =nil;
    self.window.rootViewController = mainRevealController;
    [self.window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)

这可行,但创建了一个新的Navigtion控制器,我需要的是使用故事板中已经定义的控制器,因为它具有特定的属性.

任何的想法?

谢谢

objective-c uiviewcontroller ios appdelegate swrevealviewcontroller

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

iBeacon监控和后台测距

我花了几个月的时间开发基于iBeacons的应用程序,我真的很沮丧.

一般的想法是,当检测到信标时,向用户通知特定于该iBeacon的信息.

该应用程序设计如下,所有iBeacons具有相同的UUID,Major决定建筑物(博物馆,商店......)和Minor特定产品(图片,鞋子......).所以这个应用程序可以服务多个客户

当应用程序启动时,我开始使用我们的UUID对区域进行监视和测距.当应用程序处于前台时,一切都很完美.但是在背景或暂停状态下,问题就开始了.在背景或暂停状态下不允许测距.

我知道当您进入或退出信标区域时,应用程序将在后台启动约5秒钟.你可以在这五秒钟的后台进行测距,之后iOS会再次暂停你的应用程序.

我设法通过这里学到的技术在后台扩展了最多3分钟.我还通过notifyEntryStateOnDisplay = YES获得额外的回调;

但这还不够,如果客户进入应用程序处于后台或暂停状态的区域,他将收到通知.在额外的3分钟内,如果测距检测到另一个iBeacon,他将收到通知,但是当3分钟后台任务到期时,如果没有触发任何区域退出,他将不再收到任何通知.

在这样的场景中没有真正的解决方案吗?我认为这是一个非常常见的情况,我很惊讶没办法处理它.

编辑:我试图通过监测两个地区作为推荐David Young的回答来找到问题的解决方案.为了获得更多的进入/退出地区事件.

我添加了我实现的代码,试图监控两个区域.

但是我做错了一些事情和didRangeBeacons:InRegion:当预期是每秒时,回调每10毫秒触发一次.

AppDelegate.m,我正在做以下内容didFinishLaunchingWithOptions:

[self.locationManager startMonitoringForRegion:self.beaconRegion];
        [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
        [self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
        [self.locationManager startMonitoringForRegion:self.beaconRegion2];
        [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion2];
        [self.locationManager startRangingBeaconsInRegion:self.beaconRegion2];
Run Code Online (Sandbox Code Playgroud)

然后,开启 didRangeBeacons:InRegion:

- (void) locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region{

     if(beacons.count > 0){
          [self.locationManager stopRangingBeaconsInRegion:region];
          for (CLBeacon *beacon in beacons){
             NSLog(@"beacon detected major: %@ minor: %@", beacon.major,beacon.minor);
          }
           [self.locationManager startRangingBeaconsInRegion:region];   
     }

}
Run Code Online (Sandbox Code Playgroud)

当我在模拟器上运行应用程序,并且每个网络的信标都在范围内时,大约每10毫秒就会在控制台上显示该消息.

我怀疑停止并重新启动测距是打破预期的回调流程,但当只有一个区域在范围内时,回调按预期每秒发生一次.

core-location ios ibeacon

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

在uitableview中选择时更改自定义单元格图像颜色?

我有一个带有imageview和label的自定义单元格.当用户在tableview中选择一个特定单元格时,我想要更改图像颜色或色调.我设法改变了标签的颜色,但不知道如何处理图像.有任何想法吗?

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

         static NSString *CellIdentifier = @"MenuCell";

        MenuTableViewCell *cell = (MenuTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {

            cell = [[MenuTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
           // cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }


        cell.lblTitle.text = [[_items objectAtIndex:[indexPath row]] valueForKey:@"title"];
        cell.imgIcon.image = [UIImage imageNamed:[[_items objectAtIndex:[indexPath row]] valueForKey:@"image"]];
        cell.lblTitle.highlightedTextColor = [UIColor colorWithRed:0.839 green:0.682 blue:0.047 alpha:1];
       cell.selectionStyle = UITableViewCellSelectionStyleGray;
        return cell;
    }
Run Code Online (Sandbox Code Playgroud)

谢谢

objective-c uitableview uiimage tableviewcell ios

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