简体   繁体   English

苹果手表应用程序冲突uiview扩展

[英]apple watch app conflict uiview extension

I've tried to add a AppleWatch App to my own app.But I got a error says: Cannot find interface declaration for 'UIView' ,pointed to a file in which i define an extension for UIView,Which looks like below(I've add import UIKit/UIKit.h> code in pch file: 我试图将AppleWatch App添加到自己的应用程序中。但是我收到一条错误消息: 找不到'UIView'的接口声明 ,指向我在其中定义UIView扩展名的文件,如下图所示(I' ve在pch文件中添加import UIKit / UIKit.h>代码:

UIView+KKFrameExtension.h
@interface UIView (KKFrameExtension)
@property (nonatomic,assign) CGFloat  width;
@property (nonatomic,assign) CGFloat  height;
@property (nonatomic,assign) CGFloat  x;
@end

UIView+KKFrameExtension.m
-(CGFloat)width{
return self.frame.size.width;
}

-(void)setWidth:(CGFloat)width{
    CGRect frame = self.frame;
    frame.size.width = width;
    self.frame = frame;
}

// height
-(CGFloat)height{
    return self.frame.size.height;
}

-(void)setHeight:(CGFloat)height{
    CGRect frame = self.frame;
    frame.size.height = height;
    self.frame = frame;
}

but if I delete my WatchApp,everything goes well,so what happened,what should I do?Thanks 但是如果我删除WatchApp,一切正常,那么发生了什么,我该怎么办?

WatchKit does not use UIViews. WatchKit不使用UIViews。 Nor does it use UIViewControllers. 它也不使用UIViewControllers。 It uses WKInterfaceControllers. 它使用WKInterfaceControllers。 Generally, UI is created in the watch app storyboard, so you'll have to create what you want there. 通常,UI是在手表应用程序的故事板上创建的,因此您必须在其中创建所需的内容。 When you created your watch targets, you should have gotten targets for a watch app and a watch extension. 创建手表目标时,您应该已经获得了手表应用和手表扩展的目标。 The storyboard will be in the watch app (in fact, that's about all it has), and the code to manipulate it will be in the watch extension. 情节提要将在watch应用程序中(实际上,这就是它的全部内容),而操纵它的代码将在watch扩展程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM