从circleOfButtons:buttonSize:radius:
中调用SGView
中的函数ParentView
(如下),每当ParentView
向SGView
发送消息时,我都希望ParentView
在SGView
中定义值。
这是实现文件。
#import <UIKit/UIKit.h>
#import “ParentView.h"
#import "SGView.h"
@implementation ParentView : UIView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:[UIScreen mainScreen].bounds];
if (self) {
self.backgroundColor = [UIColor lightGrayColor];
int count = 5;
CGFloat size = 80.0;
CGFloat radius = 68;
SGView *myView = [SGView circleOfButtons:count buttonSize:size radius:radius];
[self addSubview:myView];
}
return self;
}
SGView将多个UIButton排列成一个圆圈,本质上是这样的
#import "SGView.h"
@implementation SGView : UIView
+(id)circleOfButtons:(int)buttonCount buttonSize:(CGFloat)buttonSize circleRadius:(CGFloat)circleRadius
{
UIView *multipleViews = [self new];
// … circular geometry …
[multipleViews addSubview:circleButton];
}
return multipleViews;
}
@end
错误消息-在
SGView *myView
行-是:没有已知的选择器类方法
'circleOfButtons:buttonSize:radius:'
我的猜测是编译器要在接口中声明。我正在尝试通过these tutorials来确定界面文件的外观,尽管有6个SO问题可能已经回答了我的问题,但只有this one的示例似乎含糊其辞。
这是我的界面文件。
#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "SGView.h"
@interface ParentView : UIView {
}
+(id)circleOfButtons:(int)buttonCount buttonSize:(CGFloat)buttonSize circleRadius:(CGFloat)circleRadius;
@end
任何人都可以举例说明此接口文件的外观吗?谢谢。
更新
这是
SGView.h
(修订版)#import <UIKit/UIKit.h>
@interface SGView : UIView {
}
+(id)circleOfButtons:(int)buttonCount buttonSize:(CGFloat)buttonSize circleRadius:(CGFloat)circleRadius;
@end
我还注意到,如果
SGView *myView = [SGView circleOfButtons:count buttonSize:size radius:radius];
更改为
SGView *myView = [self circleOfButtons:count buttonSize:size radius:radius];
错误变为
'ParentView'的可见@interface没有声明选择器'circleOfButtons:buttonSize:radius:'
以前是
选择器'circleOfButtons:buttonSize:radius:'的未知类方法
最佳答案
你在打电话
SGView *myView = [SGView circleOfButtons:count buttonSize:size radius:radius];
它应该是
SGView *myView = [SGView circleOfButtons:count buttonSize:size circleRadius:radius];
关于ios - 选择器'circleOfButtons:buttonSize:radius:'的未知类方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43138769/