我的iOS应用程序通过WatchConnectivity框架及时发送信息.接收方实现WCSession的委托.
我有2个interfaceControllers需要从WCSession发送的信息.
一个是glanceInterfaceController,另一个是我的mainInterfaceController.
是否可以为它们分配代理并同时接收从我的iOS应用程序发送的userInfo或applicationContext?或者只能分配一个WCSession委托,我的控制器需要从分配的对象获取数据?
谢谢!
AUAudioUnit和AVAudioUnit API看起来都非常相似,
有什么不同?什么时候使用哪个?
我正在尝试构建自定义警报应用程序.但我面临的挑战是在应用程序处于后台时播放声音.
第一种方法,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
除了以上两种方法都不起作用外,我似乎找不到任何其他方法来解决手头的问题. …
我想尝试新的Apple Watch OS2.
Watch App永远不会推出.大约5分钟后,我在Xcode中收到此错误消息.

我还没有添加任何Swift代码.我所做的只是添加目标并执行上述步骤.
其他人面临类似的情况?
在旧的WatchOS1中,任何数据共享都需要应用程序组.
在WatchOS2中,Watch Connectivity取代了旧的通信框架.
我想知道是否还需要应用程序组?
我正在整合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) 我正在使用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) ios ×7
apple-watch ×3
mopub ×2
objective-c ×2
watchkit ×2
watchos-2 ×2
admob ×1
ads ×1
alarm ×1
core-audio ×1
ios8 ×1
swift ×1
swift2 ×1
xcode ×1
xcode7 ×1