面试必须问的一个:
1.单例;
//创建一个单例飞机
//创建一个单例飞机
+ (Plane *)sharePlane {//单例不需要释放
static Plane * plane;
if (!plane) {
plane = [[Plane alloc]init];
}
return plane;
}
for (int i =1; i < 14; i++) {
UIImage *image = [UIImageimageNamed:[NSStringstringWithFormat:@"png%d.png",i]];
[_images addObject:image];
}
UIImageView *imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(0,100, 320, 200)];
//设置默认图片
imageView.image = [UIImageimageNamed:@"png1.png"];//动画结束之后会显示默认图片一般要设置一下
//设置简易动画
//设置动画数组(首先要有一个图片数组)
imageView.animationImages = _images;
//设置动画周期 (播放一组动画需要的时间)
imageView.animationDuration = 0.5;
//设置动画播放的次数/这个数组播放多少次
imageView.animationRepeatCount =0;//0代表无限次
3.协议 。让你写一个协议
protocol ChangeColor <NSObject>
- (void)changeColor;
@end
[_delegate changeColor];//修改第一张视图的背景颜色 一般要在这里回调方法
@interface SubViewController : UIViewController
{
id <ChangeColor> _delegate;
}
@property (nonatomic,assign)id <ChangeColor> delegate;
#import <UIKit/UIKit.h>
#import "SubViewController.h"
@interface RootViewController :UIViewController <ChangeColor>//RootViewController遵守SubViewController制定的协议
- (void)changeColor {
}
}