我有10个uiview控制器,每个都为用户创建一种问题
每个都有几层,uilabels和数据
当用户的回答正确并且“ disp_fail_anim ”时答案是错的。
这两个新控制器需要包含主视图控制器的所有子视图和数据
然后他们再创建几个图层,然后开始动画
我的问题是我不知道如何将整个viewcontroller传递给' disp_fail_anim '让我们说
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Calling the NSobject to create the data of the app
// ================================================================================
circleModel = [[Circles_3 alloc] init];
// Draw a shape
// ================================================================================
UIColor * colr = [UIColor colorWithRed:0.55 green:0.55 blue:0.55 alpha:1.0];
CAShapeLayer * down_rect = [CAShapeLayer layer];
CGRect low_rect= [[circleModel.Architectural_rectangles objectForKey:@"Control_rect"] CGRectValue];
down_rect.path = [UIBezierPath bezierPathWithRect:low_rect].CGPath;
down_rect.fillColor = [UIColor clearColor].CGColor;
down_rect.strokeColor = colr.CGColor;
down_rect.lineWidth = 1.5;
[self.view.layer addSublayer:down_rect];
// Display some text
// ================================================================================
NSAttributedString * Que_Text=circleModel.Question_string;
CGRect recty= [[circleModel.Architectural_rectangles objectForKey:@"Question_rect"] CGRectValue];
UILabel *Question_text = [[UILabel alloc] initWithFrame:recty];
Question_text.AttributedText = Que_Text;
Question_text.numberOfLines = 0;
Question_text.adjustsFontSizeToFitWidth = YES;
Question_text.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:Question_text];
}
// Then i have some touch methods and when the touch is over
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (circleModel.Correct_answer==button)
disp_correct_anim * correct_anim = [[disp_correct_anim alloc] init];
else
disp_fail_anim * fail_anim = [[disp_fail_anim alloc] init];
}
// The 'disp_fail_anim' and 'disp_correct_anim' are 2 animations each being a viewcontroller.
答案 0 :(得分:1)
你听起来很困惑。动画不是视图控制器。视图控制器不与其他视图控制器共享视图。
听起来我需要为所有视图控制器创建一个父类,它实现了几个常见的动画方法,一个用于正确答案,另一个用于错误答案。所有10个视图控制器都是这个基类的子类,因此内置了它们的方法。