Objective-C 프로그래밍에 익숙하며 일반적인 메모리 문제가 있습니다. 내비게이션 컨트롤러를 기반으로하는 앱을 수행해야하며 푸시보기 컨트롤러를 사용하여 몇 개의보기를 전달할 때 100 개의 이미지 애니메이션을로드해야합니다. 시뮬레이터에서는 잘 작동하지만 전화에서는 그렇지 않습니다. 다른 애니메이션을 연 다음 닫습니다. 그것을 피하기 위해 호를 사용하고 있지만 작동하지 않는 것 같습니다. 또한 arc를 비활성화하고 UIImageView를 수동으로 릴리스하려고 시도했지만 빠르게 충돌합니다. 보기 중 하나의 예는 다음과 같습니다.아크를 이용한 메모리 문제
//.h
@interface Gegant_nou : UIViewController {
IBOutlet UIImageView *ImageViewGegant;
}
@property (nonatomic, strong) UIImageView* ImageViewGegant;
//.m
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *rigthButton = [[UIBarButtonItem alloc] initWithTitle:@"Detalls" style:UIBarButtonItemStyleBordered target:self action:@selector(canviarDetalls)];
self.navigationItem.rightBarButtonItem = rigthButton;
[rigthButton release];
ImageViewGegant.animationImages [email protected]
[[UIImage imageNamed:@"0001.png"],
[UIImage imageNamed:@"0002.png"],
. load all the images
.
[UIImage imageNamed:@"0099.png"],
[UIImage imageNamed:@"0100.png"]];
ImageViewGegant.animationDuration = 4;
ImageViewGegant.animationRepeatCount = 0;
[ImageViewGegant startAnimating];
[self.view addSubview:ImageViewGegant];
self.title = @"Gegant nou";
[ImageViewGegant release];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload{
[super viewDidUnload];
[ImageViewGegant release];
}
어떤 아이디어가 발생합니까? 도와 주셔서 감사합니다!
1. 어떤 줄이 예외를 던집니까? 2.'-viewDidUnload'는 iOS6에서 사용하지 않는 것이 좋습니다 (절대로 호출되지 않습니다). 3. 왜 루프를 사용하여 이미지 배열을 초기화하지 않습니까? – holex
ImageNamed를 사용하여 vs initwtihcontentsoffile을로드 할 때 메모리 사용에 대한 몇 가지 논쟁이 있습니다. 다른 옵션에 대한 좋은 정보는이 게시물을 참조하십시오. http://stackoverflow.com/questions/6566827/iphone-ios-how-to-load-a-lot-of-image-in-many-folder-and-show -in-a-table-view –
@holex viewDidUnload 대신 무엇을 사용해야합니까? 탈락? – joan2404