我有一个让我头疼的项目,我想这是因为我需要在实践中学习,因此我错过了iOS中的一些基本内容,所以不要对我大喊大叫!:-)
我有一个iOS iPad故事板,由大约。33-35 ViewControllers。这个概念是“世界”,你按视图往下走,直到你接触到表面,我有一个动画的UIImage (25png,1,7f持续时间)。由于presentModalView只是覆盖旧视图,而不是在其他视图从底部进入时将其向上推送,因此我添加了UIViewController+Transitions ( http://srooltheknife.blogspot.no/2012/03/custom-transition-animation-for-modal.html ),以便也动画删除旧视图,它工作得很完美。但是,当我使用这个额外的库时,每当我在UIImageView中使用动画时,所有的触摸事件似乎都被禁用了。我在视图、按钮、视图上都尝试了enableUserInteraction = YES,但没有帮助。
有什么想法吗?
下面是包含动画的viewController:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Main world view loaded....");
NSLog(@"Bounds = %@", NSStringFromCGRect(self.view.bounds));
//self.view.bounds = self.view.frame;
NSLog(@"Bounds are now = %@", NSStringFromCGRect(self.view.bounds));
self.view.clipsToBounds = YES;
self.navigationController.navigationBarHidden = YES;
self.view.userInteractionEnabled = YES;
NSLog(@"User interaction is enabled?= %i", self.view.userInteractionEnabled);
// Do any additional setup after loading the view, typically from a nib.
NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i=1; i<=24; i++) {
[images addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Untitled-%d", i] ofType:@"png"]]];
}
world.animationImages = images;
world.animationDuration = 1.7;
[world startAnimating];
NSLog(@"Preparing audio");
NSURL *audioURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"mainWorldSound" ofType:@"wav"]];
NSError *audioError;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&audioError];
if(audioError){
NSLog(@"Error in audioplayer: %@", [audioError localizedDescription]);
} else {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:NULL];
player.numberOfLoops = -1;
player.volume = 1.0;
if([player isPlaying]){
[player stop];
}
[player prepareToPlay];
[player play];
NSLog(@"Playing with volume: %f", player.volume);
}
[self.view setNeedsLayout];
[self.view setNeedsDisplay];
}所以在这个视图加载之前,我有5个视图控制器,它只是文本和图片,带有向下的卷帘事件。这是加载新ViewController (如上)并在中为其设置动画的代码:
- (IBAction)goToMainWorld:(id)sender {
[self doVolumeFade];
ViewController *mainWorld = [self.storyboard instantiateViewControllerWithIdentifier:@"mainWorld"];
[self presentModalViewController:mainWorld withPushDirection:kCATransitionFromBottom];
}为了让事情更容易看到,我从我的故事板中添加了一个屏幕截图..这里(我还不能发布图片):enter link description here
我还尝试修改UIViewController+Transitions.m以使用navigationController缺省值
[self presentModalViewController:modalView animate:NO];至:
[self.navigationController presentModalViewcontroller:modal view animate:NO];但如果我这样做,它加载第一个动画视图控制器很好,但所有其他只是第一个视图控制器被重新动画,如果这是有意义的?
很抱歉我的英语不好!
如果我需要提供更多代码,请让我知道!:-)..
谢谢
发布于 2012-09-07 22:06:52
好的..。我自己已经弄明白了,似乎我为每个“视图”使用视图的技术并不是一个好主意。
我从来没有见过UIScrollView,觉得值得一试,似乎这是我的解决方案。
MemoryVise大致相同,但我现在得到了市场营销想要的过渡等。
现在唯一的问题是让每个ScrollView页面的声音淡入淡出,并在底部的第二个UIScrollView中控制声音,这似乎让我有些头疼。
感谢奥顿
https://stackoverflow.com/questions/12245458
复制相似问题