问题
In my application the user can add any number of images to the view. If he tries to add more images of bigger in memory size the application receives memory warning . So I want to display an alert to don't add images after receiving memory warning level = 2. Is it possible If so please help me. Thank You
回答1:
For User Experience sake, don't display an alert. Handling memory is your responsibility and not that of your user.
回答2:
What kind of alert do you want to dislplay? you could make an NSAlert like so:
[NSAlert alertWithError:@""];
EDIT
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
[NSAlert alertWithError:@"You cannot make any more pictures"];
canTakePicture = NO;
}
Create an instance variable called canTakePicture of type BOOL. When making a picture you should check if "canTakePicture" is YES or NO.
回答3:
In the didReceiveMemoryWarning write alertView.
- (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.}
回答4:
Your view controller method didReceiveMemoryWarning
is called when application runs out of memory. Here you can create a alertview
and display the appropriate message.
In general handle the warning here.
来源:https://stackoverflow.com/questions/6425043/how-i-can-display-an-alert-when-i-received-memory-warning-level-2-in-iphone-sdk