有没有人让CocoaPods与watchOS 2合作?我尝试过使用'use_framework!' 使用'platform:watchos,'2.0',但它说"[!]无效的Podfile文件:不支持的平台watchos2.平台必须是:ios或:osx..更新CocoaPods可能会解决问题."
我是最新版的CocoaPods.
在头文件中
#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
#import <WatchConnectivity/WatchConnectivity.h>
@interface InterfaceController : WKInterfaceController<WCSessionDelegate>
- (IBAction)lastSongButtonClick;
- (IBAction)playSongButtonClick;
- (IBAction)nextSongButtonClick;
@property (strong, nonatomic) IBOutlet WKInterfaceLabel *songTitleLabel;
@property (strong, nonatomic) IBOutlet WKInterfaceButton *playSongButton;
@end
Run Code Online (Sandbox Code Playgroud)
所以我实现了WCSessionDelegate,每次收到关于UI的内容时,我都希望它能够更新.所以在我的.m文件中我有:
- (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictionary<NSString *,id> *)message{
NSString* type = [message objectForKey:@"type"];
if([type isEqualToString:@"UIUpdateInfo"]){
NSLog(@"?Watch receives UI update info");
[self handleUIUpdateInfo:[message objectForKey:@"content"]];
}
}
Run Code Online (Sandbox Code Playgroud)
和
- (void)handleUIUpdateInfo:(NSDictionary*)updateInfo{
[self.songTitleLabel setText:[updateInfo objectForKey:@"nowPlayingSongTitle"]];
[self.playSongButton setBackgroundImage:[updateInfo objectForKey:@"playButtonImage"]];
}
Run Code Online (Sandbox Code Playgroud)
但是,它似乎没有更新.有没有适当的更新方式?
是否可以使用Watch OS 2从手表开始呼叫?我的手表os2应用程序中有一个按钮,我需要一种方法从手表开始拨打预编号的号码或至少在iPhone中启动呼叫.谢谢
我有一个不同类型的条目的时间表,我需要一种方法来导航用户到特定的接口控制器(或相同的控制器,但具有不同的上下文),具体取决于已经点击的条目类型.有没有办法处理watchOS 2下的复杂功能?
我在让 Complications 工作时遇到问题。如果我能够可靠地刷新它们,那将会很有帮助。
因此,我将强制按下菜单按钮链接到以下方法
@IBAction func updateComplication() {
let complicationServer = CLKComplicationServer.sharedInstance()
for complication in complicationServer.activeComplications {
complicationServer.reloadTimelineForComplication(complication)
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这会导致应用程序崩溃。与fatal error: unexpectedly found nil while unwrapping an Optional value.
我知道电话reloadTimelineForComplication(complication)是有预算的,但这不是这里的问题,因为它从一开始就不起作用。
我目前正在使用 watchOS2 + Xcode 7 GM
我很感激有关在应用程序运行时刷新复杂功能的任何想法?
我有一个 Apple Watch 并发症,它可以正确初始化并显示我期望的数据。但是,当我的 getNextRequestedUpdateDateWithHandler 方法中返回的 NSDate 触发刷新时,我的委托中唯一被再次调用的方法是 getNextRequestedUpdateDateWithHandler 方法(我在每个方法上设置断点来确定这一点)。我本来希望在请求的更新日期发生时调用 requestsUpdateDidBegin ,但情况似乎并非如此。有谁知道是什么原因造成的?这是我的代码:
class ComplicationController: NSObject, CLKComplicationDataSource {
/// Provide the time travel directions your complication supports (forward, backward, both, or none).
func getSupportedTimeTravelDirectionsForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationTimeTravelDirections) -> Void) {
handler(.Backward)
}
/// Depending on which time travel directions you support, you will be asked for the start/end dates of your timeline (or both, or neither).
/// The start/end dates will determine at what point during time travel we dim …Run Code Online (Sandbox Code Playgroud) iOS可以layer.cornerRadius用来制作一个回合UIButton.
是否WKInterfaceButton有这个属性?
如果没有,我怎么能WKInterfaceButton进入WatchKit.
我试图使用单例来管理WCSession消息,我在这里找到了.
我明白它想要做什么,但我不明白为什么我会收到错误...这是我正在努力的路线:
if let session = session where session.paired && session.watchAppInstalled {
Run Code Online (Sandbox Code Playgroud)
错误:'watchAppInstalled'不可用
错误:'配对'不可靠
问题:如何提供这些属性?一般来说是watchOS和ios的新手.谢谢!
整个代码:
import WatchConnectivity
class WatchSessionManager: NSObject, WCSessionDelegate {
static let sharedManager = WatchSessionManager()
private override init() {
super.init()
}
private let session: WCSession? = WCSession.isSupported() ? WCSession.defaultSession() : nil
private var validSession: WCSession? {
// paired - the user has to have their device paired to the watch
// watchAppInstalled - the user must have your watch app installed
// Note: …Run Code Online (Sandbox Code Playgroud) 使用导入,我可以将此模块用于iPhone,但不能用于Apple Watch应用程序。我也想使用此库编写Apple Watch应用程序。可能吗?如果可能的话,怎么办?如果无法解决,您能否提供替代方法?
预先感谢
iPhone的HTTP请求的简单示例
import Alamofire
Alamofire.request(.GET, requestUrl, headers: self.headers(), encoding:.JSON).responseJSON
{
(rJ) -> Void in
let data = rJ.result.value
let err = rJ.result.error
}
Run Code Online (Sandbox Code Playgroud) watchos-2 ×10
watchkit ×7
ios ×4
swift ×3
apple-watch ×2
clockkit ×2
cocoapods ×1
flurry ×1
ios9 ×1
objective-c ×1
phone-call ×1
watchos ×1
wcsession ×1