在 iphone 启动画面上工作,我借助一些图像制作了自定义动画,这些图像将在横向模式下出现在我的启动画面上,然后我希望当我的第二个视图加载时它应该以纵向模式显示,但我无法实现这个,这是我的代码:
@interface SplashViewController : UIViewController
{
IBOutlet UIImageView *ani;
NSMutableArray *arr;
}
@property(strong,nonatomic)UIImageView *ani;
@property(strong,nonatomic)NSMutableArray *arr;
-(void)switchView;
@end
#import "SecondView.h"
@implementation SplashViewController
@synthesize ani,arr;
- (void)viewDidLoad
{
arr = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"image_1.png"],
[UIImage imageNamed:@"image_2.png"],[UIImage imageNamed:@"image_3.png"],
[UIImage imageNamed:@"image_4.png"],[UIImage imageNamed:@"image_5.png"],
[UIImage imageNamed:@"image_6.png"],[UIImage imageNamed:@"image_7.png"],
[UIImage imageNamed:@"image_8.png"],[UIImage imageNamed:@"image_9.png"],
[UIImage imageNamed:@"image_10.png"],[UIImage imageNamed:@"image_11.png"],
[UIImage imageNamed:@"image_12.png"],[UIImage imageNamed:@"image_13.png"],
[UIImage imageNamed:@"image_14.png"],[UIImage imageNamed:@"image_15.png"],
[UIImage imageNamed:@"image_16.png"],[UIImage imageNamed:@"image_17.png"],
[UIImage imageNamed:@"image_18.png"],[UIImage imageNamed:@"image_19.png"],
[UIImage imageNamed:@"image_20.png"],nil];
[ani setImage:[UIImage imageNamed:@"image_20.png"]];
ani.animationImages=arr;
ani.animationDuration=10;
// ani.animationRepeatCount=1.0;
[ani startAnimating];
[self performSelector:@selector(switchView) withObject:nil afterDelay:15.0];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)switchView
{
[ani stopAnimating];
SecondView *sec=[[SecondView alloc]init];
[self.view addSubview:sec.view];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
我在第二个视图中使用了一个按钮以从中删除启动视图,因此当我们单击第二个视图上的按钮时,启动视图应该关闭,或者可以在加载第二个视图时执行相同操作,但我无法实现它
-(IBAction)btn:(id)sender
{
// UIViewController
[self.view removeFromSuperview];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
注意:我不想为我的 Flash 使用 Default.png 图像视图但启动视图仍然出现在视图的背面..我只有模拟器要测试..有人可以帮我解决这个问题吗?