我有一个问题。也许我在错误的地方或什么地方有什么东西,但是我就是想不通!任何帮助,将不胜感激。
我试图简单地以编程方式制作一个仅在我的子视图中显示的时钟。
我已经设置了一个计时器以及一个我想在我创建的子视图中显示的更新器 -(void)。我正在以编程方式构建子视图,这就是不添加 IBOutlet 并将其连接到我的故事板的原因 - 我正在尝试仅使用代码来完成所有操作。
我的 updateTimer 标签上出现错误,上面写着 - 使用未声明的标识符“rightLabel”,这对我来说不起作用。哈哈 - 任何帮助将不胜感激!
。H
@interface DemoRootViewController : UIViewController <PaperFoldViewDelegate> {
NSTimer *timer;
}
@property (nonatomic, strong) UIView *rightView;
-(void)updateTimer;
.m
- (id)init
{
self = [super init];
if (self) {
//Timer Setup
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];
//PaperFold Setup
_paperFoldView = [[PaperFoldView alloc] initWithFrame:CGRectMake(0,0,[self.view bounds].size.width,[self.view bounds].size.height)];
[_paperFoldView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[self.view addSubview:_paperFoldView];
//Setup Subview
_rightView = [[UIView alloc] initWithFrame:CGRectMake(0,0,240,[self.view bounds].size.height)];
//Setup UILabel
UILabel *rightLabel = [[UILabel alloc] initWithFrame:_rightView.frame];
[_rightView addSubview:rightLabel];
//Using PaperFold Framework to Add the Subview (this works fine)
[_paperFoldView setRightFoldContentView:_rightView foldCount:2 pullFactor:1];
}
return self;
}
-(void)updateTimer {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"hh:mm:ss"];
//This is where I get my error "Use of Undeclared Identifier 'rightLabel'
rightLabel.text = [formatter stringFromDate:[NSDate date]];
}
@end