-2
У меня проблема с этим кодом:Нет видимых @interface для UIViewController заявляет селектор 'initWithFrame:'
ViewController.h
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "WheelMovementProtocol.h"
@interface ViewController : UIViewController {
}
@property int wheelNumberOfSections;
@property (weak, nonatomic) id <WheelMovementProtocol> delegate;
@property (strong, nonatomic) UIView *containerView;
- (id)initWithFrame:(CGRect)frame andDelegate:(id)del withSections:(int)sectionsNumber;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController() {
}
- (void)drawWheel;
@end
@implementation ViewController
@synthesize delegate;
@synthesize containerView;
@synthesize wheelNumberOfSections;
- (id)initWithFrame:(CGRect)frame andDelegate:(id)del withSections:(int)sectionsNumber {
if ((self = [super initWithFrame: frame])) { // Here's the error
self.wheelNumberOfSections = sectionsNumber;
self.delegate = del;
[self drawWheel];
}
return self;
}
- (void)drawWheel {
self.containerView = [[UIView alloc] initWithFrame: self.frame];
CGFloat angleRadius = 2 * M_PI/wheelNumberOfSections;
for (int i = 0; i < wheelNumberOfSections; i++) {
}
}
Я следую this tutorial о том, как создать управление вращающимся колесом и Я следую шаг за шагом, но я не могу понять, почему мой код ошибочен.
'UIViewController' не имеет метод, называемый' 'initWithFrame:. Поэтому вы не можете выполнять '[super initWithFrame: frame]', если ваш объект наследуется от 'UIViewController'. – Larme
Ваш суперкласс - UIViewController в tutotial, он подклассифицируется из UIControl – iOSfleer
«Решение должно было снова следовать учебнику и правильно создать ViewController». это весело :-) – Alf