我有这样的情况:更新视图
如果我点击左脚按钮,我想,我在第二控制器视图显示左脚形象,如果我点击右键,视图应显示右脚图像。
在第一控制器我写这个选择左或右:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
RSViewController *vc = [segue destinationViewController];
if ([[segue identifier] isEqualToString:@"Left-Foot"])
[vc setLeft:YES];
else
[vc setLeft:NO];
}
在第二控制器我有设置一个布尔值
- (void)setLeft:(BOOL)left
{
if (left) {
_left = left;
NSLog(@"LEFT UPDATED IN RSVIEWCONTROLLER");
}else {
_left = left;
NSLog(@"RIGHT UPDATED IN RSVIEWCONTROLLER");
}
}
和在同一个控制器我的方法用我的一个init在viewdidload中创建我的视图:
- (void)viewDidLoad
{
NSLog(@"meeeea");
[super viewDidLoad];
CGRect rect = CGRectMake(0, 0, 100, 100);
self.animatedCircleView = [[RSAnimatedCircleView alloc] initWithFrameFoot:rect foot:YES];
NSLog(@"Viewdidnoload");
}
在我看来(小蓝色的矩形e在图中):
- (void)setup:(BOOL)left
{
self.leftFoot = left;
}
- (void)setLeftFoot:(BOOL)leftFoot
{
_leftFoot = leftFoot;
}
- (void)awakeFromNib
{
[self setup:_leftFoot];
}
- (id)initWithFrameFoot:(CGRect)frame foot:(BOOL)left
{
self = [super initWithFrame:frame];
[self setup:left];
self.leftFoot = left;
if (self.leftFoot)
NSLog(@"Left == TRUE");
return self;
}
- (RSFootView *)footView
{
CGRect rect = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
if (self.leftFoot) {
NSLog(@"Now left is yes");
}else {
NSLog(@"left is no");
}
_footView = [[RSFootView alloc] initWithFrame:rect withLeftFoot:self.leftFoot];
[_footView setBackgroundColor:[UIColor clearColor]];
return _footView;
}
- (void)drawRect:(CGRect)rect
{
if (self.leftFoot)
NSLog(@"left ada");
else
NSLog(@"right masd");
CGFloat x = self.bounds.size.height;
CGFloat y = self.bounds.size.width;
CGFloat radius = x/2 - 15;
CGPoint center = CGPointMake(x/2, y/2);
CGFloat startAngle = DEGREES_TO_RADIANS(START_ANGLE);
CGFloat endAngle = DEGREES_TO_RADIANS(END_ANGLE);
// Drawing the sector
UIBezierPath *sector = [UIBezierPath bezierPathWithArcCenter:center
radius:radius
startAngle:startAngle
endAngle:endAngle
clockwise:YES];
sector.lineWidth = 4;
[[UIColor grayColor] setStroke];
[sector stroke];
[self setBackgroundColor:[UIColor clearColor]];
[sector addClip];
[self addSubview:self.footView];
}
在方法“drawRect”中,leftfoot值始终为false。我不知道为什么是这样的...任何人都可以帮助我吗?
谢谢