問題があります。多分私は間違った場所か何かに何かを持っているかもしれませんが、私はそれを理解することができません! どんな助けでも大歓迎です。
サブビューにのみ表示される時計をプログラムで作成しようとしています。
作成したサブビューに表示したい updater -(void) と一緒にタイマーをセットアップしました。IBOutletを追加せず、ストーリーボードに接続するだけの理由であるプログラムでサブビューを構築しています-コードだけですべてをやろうとしています。
updateTimer ラベルに、宣言されていない識別子「rightLabel」の使用というエラーが表示されますが、うまくいきません。HA HA - どんな助けでも大歓迎です!
.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