简体   繁体   中英

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:

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

WatchKit does not use UIViews. Nor does it use UIViewControllers. It uses WKInterfaceControllers. Generally, UI is created in the watch app storyboard, so you'll have to create what you want there. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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