小编Jac*_*ang的帖子

WatchOS2 WCSession WCSession可以在WatchKitExtension中拥有多少个代理?

我的iOS应用程序通过WatchConnectivity框架及时发送信息.接收方实现WCSession的委托.

我有2个interfaceControllers需要从WCSession发送的信息.

一个是glanceInterfaceController,另一个是我的mainInterfaceController.

是否可以为它们分配代理并同时接收从我的iOS应用程序发送的userInfo或applicationContext?或者只能分配一个WCSession委托,我的控制器需要从分配的对象获取数据?

谢谢!

ios swift apple-watch watchkit watchos-2

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

iOS Core Audio AUAudioUnit和AVAudioUnit有什么区别?

AUAudioUnit和AVAudioUnit API看起来都非常相似,

有什么不同?什么时候使用哪个?

core-audio audio-streaming ios

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

iOS 8自定义闹钟使用uilocalnotification并在手机静音时在后台播放声音

我正在尝试构建自定义警报应用程序.但我面临的挑战是在应用程序处于后台时播放声音.

第一种方法,UILocalNotification,

根据Apple编程指南,发出警报的正确方法是

- (void)scheduleAlarmForDate:(NSDate*)theDate
{
    UIApplication* app = [UIApplication sharedApplication];
    NSArray*    oldNotifications = [app scheduledLocalNotifications];

    // Clear out the old notification before scheduling a new one.
    if ([oldNotifications count] > 0)
        [app cancelAllLocalNotifications];

    // Create a new notification.
    UILocalNotification* alarm = [[UILocalNotification alloc] init];
    if (alarm)
    {
        alarm.fireDate = theDate;
        alarm.timeZone = [NSTimeZone defaultTimeZone];
        alarm.repeatInterval = 0;
        alarm.soundName = @"alarmsound.caf";
        alarm.alertBody = @"Time to wake up!";

        [app scheduleLocalNotification:alarm];
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是,

  • 如果用户手机处于静音状态,则通知声音只会是一个不足以发出警报的小振动.

  • 理想情况下,无论电话处于静音还是正常状态,我都希望警报能够响起,以唤醒用户.

我能想到的第二种方式,AVAudioSession

  • 但是当该区域接近或警报触发器进入时,audioSession无法在后台启动,因此任何audioPlayer.play()方法都不会执行任何操作.

除了以上两种方法都不起作用外,我似乎找不到任何其他方法来解决手头的问题. …

core-location alarm ios uilocalnotification ios8

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

Xcode 7安装Apple Watch应用程序从未完成

我想尝试新的Apple Watch OS2.

  • 打开我现有的项目
  • 添加了目标
  • 更改了分发包标识符以删除错误消息

Watch App永远不会推出.大约5分钟后,我在Xcode中收到此错误消息.

在此输入图像描述

我还没有添加任何Swift代码.我所做的只是添加目标并执行上述步骤.

其他人面临类似的情况?

xcode ios apple-watch xcode7 swift2

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

WatchOS2 Watch Connectivity仍然需要应用程序组的功能吗?

在旧的WatchOS1中,任何数据共享都需要应用程序组.

在WatchOS2中,Watch Connectivity取代了旧的通信框架.

我想知道是否还需要应用程序组?

ios apple-watch watchkit watchos-2

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

使用MoPub显示AdMob原生广告(iOS)

我正在整合MoPub SDK以调解来自Google AdMob网络的广告.我可以在实现自己的customEvent和Adapter之后显示AD,但是我无法让AD自己处理点击事件.就像我点击AdMob原生AD一样,它不会指引我到任何地方.使用Facebook和Flurry的CustomEvent和Adapter时,会自动处理点击.有人对此主题有过任何经验吗?

提前致谢.代码如下:

MPGoogleAdMobCustomEvent

@interface MPGoogleAdMobCustomEvent()
@property(nonatomic, strong)GADAdLoader *loader;
@end

@implementation MPGoogleAdMobCustomEvent

- (void)requestAdWithCustomEventInfo:(NSDictionary *)info
{
    MPLogInfo(@"MOPUB: requesting AdMob Native Ad");

    NSString *adUnitID = [info objectForKey:@"adUnitID"];

    if (!adUnitID) {

        [self.delegate nativeCustomEvent:self didFailToLoadAdWithError:MPNativeAdNSErrorForInvalidAdServerResponse(@"MOPUB: No AdUnitID from GoogleAdMob")];

        return;
    }

    self.loader = [[GADAdLoader alloc] initWithAdUnitID:adUnitID rootViewController:nil  adTypes:@[kGADAdLoaderAdTypeNativeContent] options:nil];
    self.loader.delegate = self;
    GADRequest *request = [GADRequest request];

#if (TARGET_OS_SIMULATOR)

    request.testDevices = @[ kGADSimulatorID ];

#endif

    CLLocation *location = [[CLLocationManager alloc] init].location;
    if (location) {
        [request setLocationWithLatitude:location.coordinate.latitude
                               longitude:location.coordinate.longitude
                                accuracy:location.horizontalAccuracy];
    }
    request.requestAgent = @"MoPub"; …
Run Code Online (Sandbox Code Playgroud)

ads objective-c admob ios mopub

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

MoPub如何使用具有动态单元格高度的MPTableViewAdPlacer实现iOS原生广告?

我正在使用MPTableViewAdPlacer在iOS UITableView中实现原生广告.初始化MPTableViewAdPlacer时,它会要求MPStaticNativeAdRendererSettings,它需要实现viewSizeHandler.但是,这是在提取任何广告之前,因为名称建议为"静态"原生广告.我正在尝试实现一个可以在获取adData后计算单元格高度,例如标题,图像等.我一直试图找到一种方法来实现动态单元格高度,但所有示例应用程序,twitter提供的说明仅显示静态高度实现.

代码如下:

-(void)setupAdPlacer {

    MPNativeAdRequestTargeting *targeting = [MPNativeAdRequestTargeting targeting];
    targeting.location = [[CLLocationManager alloc] init].location;

    targeting.desiredAssets = [NSSet setWithObjects: kAdMainImageKey, kAdCTATextKey, kAdTextKey, kAdTitleKey, nil];

    MPStaticNativeAdRendererSettings *settings = [[MPStaticNativeAdRendererSettings alloc] init];

    settings.renderingViewClass = [REPostListViewMoPubAdCell class];
    settings.viewSizeHandler = ^(CGFloat maximumWidth) {
    return CGSizeMake(maximumWidth, 312.0);

    // STATIC HEIGHT
    };

    MPNativeAdRendererConfiguration *config = [MPStaticNativeAdRenderer rendererConfigurationWithRendererSettings:settings];

    self.adPlacer = [MPTableViewAdPlacer placerWithTableView:self.tableView viewController:self adPositioning:positioning rendererConfigurations:@[config]];
    self.adPlacer.delegate = self;

    [self.adPlacer loadAdsForAdUnitID:@"xxxxxxxxxxx" targeting:targeting];
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios mopub facebook-audience-network

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