2012-04-26 3 views
0

안녕하세요, im은 iPad 앱을 조립하려고합니다. 모두 시뮬레이터에서는 원활하게 실행되지만 장치에서는 원활하게 실행되지 않습니다. 나는 다섯 개의 뷰 컨트롤러를 가지고 있으며 특히 몬스터 애니메이션을 실행할 때 5 번째입니다.내 애니메이션이 기기에서는 충돌하지만 시뮬레이터에서는 충돌하지 않습니다.

여기보기 컨트롤러에서 코드를 게시하고 있습니다. 웃지 마세요.

또한 메모리 경고를 받았다고합니다. 그게 뭐야?

고맙습니다.

import "FifthViewController.h" 
#import "ViewController.h" 



@interface FifthViewController() 

@end 

@implementation FifthViewController 


@synthesize doorImage; 

@synthesize flagImage; 

@synthesize kuckuImage; 

@synthesize treImage; 

@synthesize moppImage; 


-(IBAction)trollljud:(id)sender{ 
    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"trolleri3", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); } 

-(IBAction)monsterljud:(id)sender{ 
    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Monsterljud", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); } 

-(IBAction)dorrljud:(id)sender{ 
    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"dörrljud", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); } 

-(IBAction)kuckuljud:(id)sender{ 
    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Fun24", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); } 

-(IBAction)flaggljud:(id)sender{ 
    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Flag1", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); } 

-(IBAction)change:(id)sender{ 
    ViewController *two = [[ViewController alloc] initWithNibName:nil bundle:nil]; 
    two.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:two animated:YES]; 
    [theAudio stop]; 
    [two release]; 

} 


-(IBAction)hideButton 

{ 
    Button2.hidden=FALSE; } 

-(IBAction)hideButton2 

{ 
    Button3.hidden=TRUE; } 


- (void) openDoor { 
    [doorImage startAnimating]; } 

- (void) kucku { 
    [kuckuImage startAnimating]; } 

- (void) flag { 
    [flagImage startAnimating]; } 

- (void) tre { 
    [treImage startAnimating]; } 

- (void) mopp { 
    [moppImage startAnimating]; } 


-(IBAction)oneFingerSwipeLeft:(UITapGestureRecognizer *)recognizer { 

    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Droid2", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); 
    } 

-(IBAction)oneFingerSwipeRight:(UITapGestureRecognizer *)recognizer { 

    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Droid", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); 
    } 

-(IBAction)oneFingerSwipeUp:(UITapGestureRecognizer *)recognizer { 

    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Wolf2", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); 
    } 

-(IBAction)oneFingerSwipeDown:(UITapGestureRecognizer *)recognizer { 

    CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    CFURLRef soundFileURLRef; 
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Snake2", CFSTR ("mp3"), NULL); 
    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
    CFRelease(soundFileURLRef); 
    } 



- (void)viewDidLoad{ 

    { 
     [super viewDidLoad]; 

     UISwipeGestureRecognizer *oneFingerSwipeLeft = [[[UISwipeGestureRecognizer alloc] 
                 initWithTarget:self 
                 action:@selector(oneFingerSwipeLeft:)] autorelease]; 
     [oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; 
     [[self view] addGestureRecognizer:oneFingerSwipeLeft]; 

     UISwipeGestureRecognizer *oneFingerSwipeRight = [[[UISwipeGestureRecognizer alloc] 
                  initWithTarget:self 
                  action:@selector(oneFingerSwipeRight:)] autorelease]; 
     [oneFingerSwipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; 
     [[self view] addGestureRecognizer:oneFingerSwipeRight]; 

     UISwipeGestureRecognizer *oneFingerSwipeUp = [[[UISwipeGestureRecognizer alloc] 
                 initWithTarget:self 
                 action:@selector(oneFingerSwipeUp:)] autorelease]; 
     [oneFingerSwipeUp setDirection:UISwipeGestureRecognizerDirectionUp]; 
     [[self view] addGestureRecognizer:oneFingerSwipeUp]; 

     UISwipeGestureRecognizer *oneFingerSwipeDown = [[[UISwipeGestureRecognizer alloc] 
                 initWithTarget:self 
                 action:@selector(oneFingerSwipeDown:)] autorelease]; 
     [oneFingerSwipeDown setDirection:UISwipeGestureRecognizerDirectionDown]; 
     [[self view] addGestureRecognizer:oneFingerSwipeDown]; 



    } 


    { 
     [super viewDidLoad]; 

     [Button2 setHidden:TRUE]; 
    } 

    { 
     NSString *path = [[NSBundle mainBundle] pathForResource:@"Okenljud" ofType:@"mp3"]; 
     if (theAudio) [theAudio release]; 
     { 
      theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 
      [theAudio play]; 
      theAudio.numberOfLoops = -1; 
     } 
     [super viewDidLoad]; 
    } 
    { 
     [super viewDidLoad]; 
     NSArray *doorFrames = [NSArray array]; 
     doorFrames = [[NSArray alloc] initWithObjects: 
         [UIImage imageNamed:@"dörr51.png"], 
         [UIImage imageNamed:@"dörr51.png"], 
         [UIImage imageNamed:@"dörr52.png"],   
         [UIImage imageNamed:@"dörr53.png"], 
         [UIImage imageNamed:@"dörr54.png"], 
         [UIImage imageNamed:@"dörr55.png"], 
         [UIImage imageNamed:@"dörr56.png"], 
         [UIImage imageNamed:@"dörr57.png"], Nil]; 
     doorImage.animationImages = doorFrames; 
     doorImage.animationDuration = 3; 
     doorImage.animationRepeatCount = 1; 
    } 


    { 
     [super viewDidLoad]; 
     NSArray *kuckuFrames = [NSArray array]; 
     kuckuFrames = [[NSArray alloc] initWithObjects: 
         [UIImage imageNamed:@"Kuckuhh1.png"], 
         [UIImage imageNamed:@"Kuckuhh2.png"], 
         [UIImage imageNamed:@"Kuckuhh3.png"],   
         [UIImage imageNamed:@"Kuckuhh2.png"], 
         [UIImage imageNamed:@"Kuckuhh1.png"], Nil]; 
     kuckuImage.animationImages = kuckuFrames; 
     kuckuImage.animationDuration = 1; 
     kuckuImage.animationRepeatCount = 1; 
    } 

    { 
     [super viewDidLoad]; 
     NSArray *moppFrames = [NSArray array]; 
     moppFrames = [[NSArray alloc] initWithObjects: 
         [UIImage imageNamed:@"m1.png"], 
         [UIImage imageNamed:@"m2.png"], 
         [UIImage imageNamed:@"m3.png"], 
         [UIImage imageNamed:@"monster15.png"], 
         [UIImage imageNamed:@"monster16.png"], 
         [UIImage imageNamed:@"monster17.png"], 
         [UIImage imageNamed:@"m4.png"], 
         [UIImage imageNamed:@"monster18.png"], 
         [UIImage imageNamed:@"monster19.png"], 
         [UIImage imageNamed:@"m5.png"], 
         [UIImage imageNamed:@"m6.png"], 
         [UIImage imageNamed:@"m7.png"], 
         [UIImage imageNamed:@"m8.png"], 
         [UIImage imageNamed:@"m9.png"], 
         [UIImage imageNamed:@"m10.png"], 
         [UIImage imageNamed:@"m11.png"], 
         [UIImage imageNamed:@"m12.png"], 
         [UIImage imageNamed:@"m13.png"], 
         [UIImage imageNamed:@"m14.png"], 
         [UIImage imageNamed:@"monster20.png"], 
         [UIImage imageNamed:@"monster21.png"], 
         [UIImage imageNamed:@"monster22.png"], 
         [UIImage imageNamed:@"monster23.png"], 
         [UIImage imageNamed:@"monster24.png"], 
         [UIImage imageNamed:@"monster25.png"], 
         [UIImage imageNamed:@"monster26.png"], Nil]; 
     moppImage.animationImages = moppFrames; 
     moppImage.animationDuration = 19; 
     moppImage.animationRepeatCount = 1; 
    } 


    { 
     [super viewDidLoad]; 
     NSArray *fagelBilder = [NSArray array]; 
     fagelBilder = [[NSArray alloc] initWithObjects: 
         [UIImage imageNamed:@"1.png"], 
         [UIImage imageNamed:@"2.png"], 
         [UIImage imageNamed:@"3.png"], 
         [UIImage imageNamed:@"4.png"], 
         [UIImage imageNamed:@"5.png"], 
         [UIImage imageNamed:@"6.png"], 
         [UIImage imageNamed:@"7.png"], 
         [UIImage imageNamed:@"8.png"], 
         [UIImage imageNamed:@"9.png"], 
         [UIImage imageNamed:@"10.png"], 
         [UIImage imageNamed:@"11.png"], 
         [UIImage imageNamed:@"12.png"], 
         [UIImage imageNamed:@"13.png"], 
         [UIImage imageNamed:@"14.png"], 
         [UIImage imageNamed:@"15.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"16.png"], 
         [UIImage imageNamed:@"17.png"], 
         [UIImage imageNamed:@"18.png"], 
         [UIImage imageNamed:@"19.png"], 
         [UIImage imageNamed:@"20.png"], 
         [UIImage imageNamed:@"21.png"], 
         [UIImage imageNamed:@"22.png"], 
         [UIImage imageNamed:@"23.png"], 
         [UIImage imageNamed:@"24.png"], 
         [UIImage imageNamed:@"25.png"], 
         [UIImage imageNamed:@"26.png"], 
         [UIImage imageNamed:@"27.png"], 
         [UIImage imageNamed:@"28.png"], 
         [UIImage imageNamed:@"29.png"], 
         [UIImage imageNamed:@"30.png"], 
         [UIImage imageNamed:@"31.png"], 
         [UIImage imageNamed:@"32.png"], 
         [UIImage imageNamed:@"33.png"], 
         [UIImage imageNamed:@"38.png"], 
         [UIImage imageNamed:@"14.png"], 
         [UIImage imageNamed:@"13.png"], 
         [UIImage imageNamed:@"12.png"], 
         [UIImage imageNamed:@"11.png"], 
         [UIImage imageNamed:@"10.png"], 
         [UIImage imageNamed:@"9.png"], 
         [UIImage imageNamed:@"8.png"], 
         [UIImage imageNamed:@"7.png"], 
         [UIImage imageNamed:@"6.png"], 
         [UIImage imageNamed:@"5.png"], 
         [UIImage imageNamed:@"4.png"], 
         [UIImage imageNamed:@"3.png"], 
         [UIImage imageNamed:@"2.png"], 
         [UIImage imageNamed:@"1.png"], Nil]; 
     treImage.animationImages = fagelBilder; 
     treImage.animationDuration = 10; 
     treImage.animationRepeatCount = 1; 
    } 

    { 
     [super viewDidLoad]; 
     NSArray *flagbilder = [NSArray array]; 
     flagbilder = [[NSArray alloc] initWithObjects: 
         [UIImage imageNamed:@"F1.png"], 
         [UIImage imageNamed:@"f2.png"], 
         [UIImage imageNamed:@"f3.png"], 
         [UIImage imageNamed:@"f4.png"], 
         [UIImage imageNamed:@"f5.png"], 
         [UIImage imageNamed:@"f6.png"], 
         [UIImage imageNamed:@"f7.png"], 
         [UIImage imageNamed:@"f8.png"], 
         [UIImage imageNamed:@"f9.png"], 
         [UIImage imageNamed:@"f10.png"], 
         [UIImage imageNamed:@"f11.png"], 
         [UIImage imageNamed:@"f12.png"], 
         [UIImage imageNamed:@"f13.png"], 
         [UIImage imageNamed:@"f14.png"], 
         [UIImage imageNamed:@"f15.png"], 
         [UIImage imageNamed:@"f16.png"], 
         [UIImage imageNamed:@"f17.png"], 
         [UIImage imageNamed:@"f18.png"], 
         [UIImage imageNamed:@"f19.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f21.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f22.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f23.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f22.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f23.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f22.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f23.png"], 
         [UIImage imageNamed:@"f20.png"], 
         [UIImage imageNamed:@"f24.png"], 
         [UIImage imageNamed:@"f25.png"], 
         [UIImage imageNamed:@"f26.png"], 
         [UIImage imageNamed:@"f27.png"], 
         [UIImage imageNamed:@"f28.png"], 
         [UIImage imageNamed:@"f29.png"], 
         [UIImage imageNamed:@"f30.png"], 
         [UIImage imageNamed:@"f31.png"], 
         [UIImage imageNamed:@"f32.png"], 
         [UIImage imageNamed:@"f33.png"], 
         [UIImage imageNamed:@"f34.png"], 
         [UIImage imageNamed:@"f35.png"], 
         [UIImage imageNamed:@"f36.png"], 
         [UIImage imageNamed:@"f37.png"], 
         [UIImage imageNamed:@"f38.png"], Nil]; 
     flagImage.animationImages = flagbilder; 
     flagImage.animationDuration = 15; 
     flagImage.animationRepeatCount = 1; 
    } 


} 

- (void)viewDidUnload { 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; } 

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } 

@end 

답변

0

당신은 메모리 경고가 아마도 응용 프로그램이 충돌하지 않고, 과도한 메모리 사용을 위해 살해되고 얻을합니다.

클래스의 어딘가에 메모리 누수가 있거나 너무 많은 메모리를 요구할 수 있습니다.

클래스가 너무 길어 누출 여부를 조사 할 수 없습니다. 그러나 Xcode에는 문제에 대한 코드를 자동으로 분석하는 기능이 있습니다.

메뉴에서 선택하십시오 : 제품 ->분석.

가능한 문제 목록이 표시되며 출시되지 않은 모든 개체를 확인하십시오.

+0

감사합니다, MacTeo. 프로젝트를 분석 할 때 AppDelegate.m에서 두 가지 경고가 나타납니다. 여기 : - (BOOL) 응용 프로그램 : (UIApplication *) 응용 프로그램이 완료되었습니다 .LiunchingWithOptions : (NSDictionary *) launchOptions { self.window = [[UIWindow alloc] initWithFrame : [[UIScreen mainScreen] bounds]]; self.viewController = [[ViewController alloc] initWithNibName : @ "ViewController"번들 : nil]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; }보기를 전환하는 데 문제가있는 것 같습니다. 내가 어떻게 해결할 수 있는지 아십니까? 다시 한번 감사드립니다. – user1359512

+0

거기에 아무 것도 보이지 않습니다. 당신이 줄과 경고를 알려주시겠습니까? – MacTeo

0

메모리 문제가 있습니다. 시뮬레이터에는 컴퓨터의 전체 메모리 리소스가 있으며 이는 iPhone 또는 iPad보다 훨씬 뛰어납니다.

한 번에 너무 많은 이미지를로드하려고합니다. 작은 이미지를 사용하거나 이미지를 줄이거 나 애니메이션 방식을 주문형으로 변경해야 할 수도 있습니다.

또한 부차적 인 부분입니다. 당신이 가진 반복적 인 코드를 위해, "for"문과 "stringWithFormat"을 사용하십시오. 그것은 몇 줄로 떨어질 것입니다.

관련 문제