- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每次进入 View 时,使用的内存都会增加..即使我正在保存图像。有时应用程序会因内存不足警告而崩溃。有人可以告诉我解决方案,这样图像内存就不会增加。
#import <UIKit/UIKit.h>
#import "PatientStudiesViewController.h"
#import "CareServices.h"
@interface newImageComparison : UIViewController<UIScrollViewDelegate,ServerConnectionDelegate>
{
NSString *serverUrlStr;
NSString *studyID;
NSString *instID;
NSString *urlEncodedKey;
NSMutableArray *myCompareImage1;
NSMutableArray *myCompareImage2;
UIScrollView * _scrollView1;
UIScrollView * _scrollView2;
NSMutableArray *selectedStudyIDArr;
NSMutableDictionary *SelectedImageTypeDict;
NSMutableArray *selectedImagetypeTagsArr;
BOOL isRightEyeSelectedAgain;
BOOL isLeftEyeSelectedAgain;
NSMutableArray *demoCompareODArr;
NSMutableArray *demoCompareOSArr;
CareServices *careServices;
}
-(void)prepareODImages_selectedStudyIDString1 :(NSString *)selectedIDString1;
-(void)prepareOSImages_selectedStudyIDString2 :(NSString *)selectedIDString2;
- (void)loadImageRightEyeImage:(NSMutableArray *)urlAndTagReference;
- (void)loadImageLeftEyeImage:(NSMutableArray *)urlAndTagReference;
@end
#import "newImageComparison.h"
#import "XMLParserForStudyDetails.h"
#import "ColorSchemes.h"
#import <CommonCrypto/CommonDigest.h>
#import "mach/mach.h"
@implementation newImageComparison
- (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.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
careServices = [CareServices currentInstance];
careServices.delegate = self;
NSUserDefaults *selectedStudy = [NSUserDefaults standardUserDefaults];
selectedStudyIDArr = [selectedStudy valueForKey:@"selectedStudyIDArray"];
NSUserDefaults *selectedImagetype = [NSUserDefaults standardUserDefaults];
SelectedImageTypeDict = [selectedImagetype valueForKey:@"imageTypeDict"];
NSUserDefaults *selectedImageTypeTags = [NSUserDefaults standardUserDefaults];
selectedImagetypeTagsArr = [selectedImageTypeTags valueForKey:@"selectedImageTypeTags"];
NSMutableArray *imageType = [[NSMutableArray alloc]init];
for (int count = 0; count <[selectedImagetypeTagsArr count]; count++) {
[imageType addObject:[SelectedImageTypeDict valueForKey:[selectedImagetypeTagsArr objectAtIndex:count]]];
}
self.view.backgroundColor = [UIColor blackColor];
[super viewDidLoad];
myCompareImage1 = [[NSMutableArray alloc]init];
myCompareImage2 = [[NSMutableArray alloc]init];
NSUserDefaults *realUrl = [NSUserDefaults standardUserDefaults];
serverUrlStr = [realUrl valueForKey:@"serverUrl"];
NSString *key;
NSUserDefaults *keyD = [NSUserDefaults standardUserDefaults];
key = [keyD valueForKey:@"key"];
urlEncodedKey = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)key, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingASCII);
NSUserDefaults *studyID_D = [NSUserDefaults standardUserDefaults];
studyID = [studyID_D valueForKey:@"studyID"];
NSUserDefaults *instID_D = [NSUserDefaults standardUserDefaults];
instID = [instID_D valueForKey:@"instID"];
NSMutableArray *selectedDateArray = [[NSUserDefaults standardUserDefaults]valueForKey:@"selectedDateArray"];
demoCompareODArr = [[NSMutableArray alloc]init];
demoCompareOSArr = [[NSMutableArray alloc]init];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(60, 2, 200, 20)];
label.backgroundColor = [UIColor clearColor];
label.text = [NSString stringWithFormat:@"%@/%@/%@",[selectedStudyIDArr objectAtIndex:0],[selectedDateArray objectAtIndex:0],[imageType objectAtIndex:0]];
label.font = [UIFont systemFontOfSize:15];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor greenColor];
[self.view addSubview:label];
[label release];
label = [[UILabel alloc]initWithFrame:CGRectMake(60, 208, 200, 20)];
label.text = [NSString stringWithFormat:@"%@/%@/%@",[selectedStudyIDArr objectAtIndex:1],[selectedDateArray objectAtIndex:1],[imageType objectAtIndex:1]];
label.font = [UIFont systemFontOfSize:15];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor greenColor];
label.textAlignment = UITextAlignmentCenter;
[self.view addSubview:label];
[label release];
NSMutableDictionary *selectedDemoImagesDict = [[NSUserDefaults standardUserDefaults]valueForKey:@"selectedDemoImagesDict"];
if ([[imageType objectAtIndex:0] isEqualToString:@"OD"]) {
[self prepareODImages_selectedStudyIDString1:[selectedStudyIDArr objectAtIndex:0]];
}
else {
isLeftEyeSelectedAgain = YES;
[self prepareOSImages_selectedStudyIDString2:[selectedStudyIDArr objectAtIndex:0]];
}
if ([[imageType objectAtIndex:1]isEqualToString:@"OS"]) {
[self prepareOSImages_selectedStudyIDString2:[selectedStudyIDArr objectAtIndex:1]];
}
else {
isRightEyeSelectedAgain = YES;
[self prepareODImages_selectedStudyIDString1:[selectedStudyIDArr objectAtIndex:1]];
}
self.navigationItem.title = @"Image Comparsion";
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidAppear:(BOOL)animated {
UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(27,23,265,184)];
imageView1.image = [UIImage imageNamed:@"plainbg_3.png"];
[self.view addSubview:imageView1];
UIImageView *imageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(27,228,265,184)];
imageView2.image = [UIImage imageNamed:@"plainbg_3.png"];
[self.view addSubview:imageView2];
_scrollView1 = [[UIScrollView alloc]initWithFrame:CGRectMake(33,30,252,172)];
_scrollView1.delegate = self;
_scrollView1.backgroundColor = [UIColor clearColor];
_scrollView1.pagingEnabled = YES;
_scrollView1.scrollEnabled = YES;
[self.view addSubview:_scrollView1];
_scrollView2 = [[UIScrollView alloc]initWithFrame:CGRectMake(33,234,252,172)];
_scrollView2.delegate = self;
_scrollView2.backgroundColor = [UIColor clearColor];
_scrollView2.pagingEnabled = YES;
_scrollView2.scrollEnabled = YES;
[self.view addSubview:_scrollView2];
int x_val = -252;
int y_val = 0;
float dis = 0;
for (int seriesCount = 0; seriesCount <[myCompareImage1 count]; seriesCount++) {
NSMutableArray *OD = [[NSMutableArray alloc]init];
OD = [myCompareImage1 objectAtIndex:seriesCount];
for (int count = 0; count <[OD count]; count++) {
dis = dis+252;
UIImageView *R_EyeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x_val+dis, y_val, 252, 172)];
R_EyeImageView.backgroundColor = [UIColor blackColor];
R_EyeImageView.tag = seriesCount *100+100+count;
[_scrollView1 addSubview:R_EyeImageView];
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activity setFrame:CGRectMake(R_EyeImageView.frame.size.width/2.3,R_EyeImageView.frame.size.height/2.2, 40, 40)];
activity.tag = seriesCount*100+100+count;
[R_EyeImageView addSubview:activity];
[activity startAnimating];
[activity release];
[R_EyeImageView release];
}
[self loadImageRightEyeImage:OD];
[OD release];
}
_scrollView1.contentSize = CGSizeMake(dis, 0);
dis = 0;
for (int seriesCount = 0; seriesCount <[myCompareImage2 count]; seriesCount++) {
NSMutableArray *OS = [[NSMutableArray alloc]init];
OS = [myCompareImage2 objectAtIndex:seriesCount];
for (int count = 0; count <[OS count]; count++) {
dis = dis+252;
UIImageView *L_EyeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x_val+dis, y_val, 252, 172)];
L_EyeImageView.backgroundColor = [UIColor blackColor];
L_EyeImageView.tag = seriesCount *100+100+count;
[_scrollView2 addSubview:L_EyeImageView];
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activity setFrame:CGRectMake(L_EyeImageView.frame.size.width/2.3,L_EyeImageView.frame.size.height/2.2, 40, 40)];
activity.tag = seriesCount*100+100+count;
[L_EyeImageView addSubview:activity];
[activity startAnimating];
[activity release];
[L_EyeImageView release];
}
[self loadImageLeftEyeImage:OS];
[OS release];
}
_scrollView2.contentSize = CGSizeMake(dis, 0);
[_scrollView1 release];
[_scrollView2 release];
[imageView1 release];
[imageView2 release];
}
- (void)prepareODImages_selectedStudyIDString1:(NSString *)selectedIDString1 {
NSMutableArray *arr = [[XMLParserForStudyDetails sharedManager].final_ImagesDict valueForKey:selectedIDString1];
NSMutableArray *imageIDArr = [[XMLParserForStudyDetails sharedManager].imageID_RefDict_3D valueForKey:selectedIDString1];
NSMutableArray *seriesID = [[XMLParserForStudyDetails sharedManager].SeriesRefID_Dict valueForKey:selectedIDString1];
for (int count = 0; count <[seriesID count]; count++) {
NSMutableDictionary *imageDict = [arr objectAtIndex:0];
NSMutableArray *imageIDArr2 = [imageIDArr objectAtIndex:count];
NSString *seriesID1 = [seriesID objectAtIndex:count];
NSMutableArray *arr = [[NSMutableArray alloc]init];
NSMutableDictionary *imageDict2 = [imageDict valueForKey:seriesID1];
for (int count2 = 0; count2 <[imageIDArr2 count]; count2++) {
NSString *str;
NSMutableDictionary *imageDict3 = [imageDict2 valueForKey:[imageIDArr2 objectAtIndex:count2]];
if ([[imageDict3 valueForKey:@"imageType"] isEqualToString:@"image"]) {
if ([[imageDict3 valueForKey:@"num_frames"]isEqualToString:@"1"]) {
if ([[imageDict3 valueForKey:@"laterality"] isEqualToString:@"R"]) {
str = [[NSString alloc]initWithFormat:@"http://%@/i2icareclientws/i2iCareAPI_Service.asmx/GetImage?key=%@&study_id=%@&series_id=%@&image_id=%@&image_level=3&format=&frame_number=&imageType=1",serverUrlStr,urlEncodedKey,selectedIDString1,seriesID1,[imageIDArr2 objectAtIndex:count2]];
[arr addObject:str];
[str release];
}
}
}
}
if (isRightEyeSelectedAgain == YES) {
[myCompareImage2 addObject:arr];
isRightEyeSelectedAgain = NO;
}
else {
[myCompareImage1 addObject:arr];
}
[arr release];
}
}
- (void)prepareOSImages_selectedStudyIDString2:(NSString *)selectedIDString2 {
NSMutableArray *arr = [[XMLParserForStudyDetails sharedManager].final_ImagesDict valueForKey:selectedIDString2];
NSMutableArray *imageIDArr = [[XMLParserForStudyDetails sharedManager].imageID_RefDict_3D valueForKey:selectedIDString2];
NSMutableArray *seriesID = [[XMLParserForStudyDetails sharedManager].SeriesRefID_Dict valueForKey:selectedIDString2];
for (int count = 0; count <[seriesID count]; count++) {
NSMutableDictionary *imageDict = [arr objectAtIndex:0];
NSMutableArray *imageIDArr2 = [imageIDArr objectAtIndex:count];
NSString *seriesID1 = [seriesID objectAtIndex:count];
NSMutableArray *arr = [[NSMutableArray alloc]init];
NSMutableDictionary *imageDict2 = [imageDict valueForKey:seriesID1];
for (int count2 = 0; count2 <[imageIDArr2 count]; count2++) {
NSString *str;
NSMutableDictionary *imageDict3 = [imageDict2 valueForKey:[imageIDArr2 objectAtIndex:count2]];
if ([[imageDict3 valueForKey:@"imageType"] isEqualToString:@"image"]) {
if ([[imageDict3 valueForKey:@"num_frames"]isEqualToString:@"1"]) {
if ([[imageDict3 valueForKey:@"laterality"] isEqualToString:@"L"]) {
str = [[NSString alloc]initWithFormat:@"http://%@/i2icareclientws/i2iCareAPI_Service.asmx/GetImage?key=%@&study_id=%@&series_id=%@&image_id=%@&image_level=3&format=&frame_number=&imageType=1",serverUrlStr,urlEncodedKey,selectedIDString2,seriesID1,[imageIDArr2 objectAtIndex:count2]];
[arr addObject:str];
[str release];
}
}
}
}
if (isLeftEyeSelectedAgain == YES) {
[myCompareImage1 addObject:arr];
isLeftEyeSelectedAgain = NO;
}
else {
[myCompareImage2 addObject:arr];
}
[arr release];
}
}
- (void)loadImageRightEyeImage:(NSMutableArray *)urlAndTagReference {
for (int count = 0; count <[myCompareImage1 count]; count ++) {
for (int i = 0; i < [urlAndTagReference count]; i++) {
NSString *imagePath = [urlAndTagReference objectAtIndex:i];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"amp;" withString:@""];
imagePath = [imagePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *key = [self sha1:imagePath];
NSString *fileToSave = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg",key]];
for ( UIImageView *imgView in _scrollView1.subviews) {
if (imgView.tag == count *100+100+i) {
for (UIActivityIndicatorView *activity in [imgView subviews]) {
if ([activity isKindOfClass:[UIActivityIndicatorView class]]) {
if (activity.tag == count *100+100+i) {
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fileToSave];
if (!fileExists)
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
dispatch_async(queue, ^{
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
UIImage *image = [[UIImage alloc] initWithData:imageData];
NSData *jpegData = UIImageJPEGRepresentation(image,0.001);
[[NSFileManager defaultManager] createFileAtPath:fileToSave contents:jpegData attributes:nil];
dispatch_sync(dispatch_get_main_queue(), ^{
imgView.image = image;
[activity stopAnimating];
[activity removeFromSuperview];
});
});
}else{
UIImage *image = [UIImage imageWithContentsOfFile:fileToSave];
if(!image) image = [UIImage imageNamed:@"rest-blank-thumbnail.png"];
imgView.image = image;
[activity removeFromSuperview];
}
}
}
}
}
}
}
}
}
- (void)loadImageLeftEyeImage:(NSMutableArray *)urlAndTagReference {
for (int count = 0; count <[myCompareImage2 count]; count ++) {
for (int i = 0; i < [urlAndTagReference count]; i++) {
NSString *imagePath = [urlAndTagReference objectAtIndex:i];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"amp;" withString:@""];
imagePath = [imagePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *key = [self sha1:imagePath];
NSString *fileToSave = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg",key]];
for ( UIImageView *imgView in _scrollView2.subviews) {
if (imgView.tag == count *100+100+i) {
for (UIActivityIndicatorView *activity in [imgView subviews]) {
if ([activity isKindOfClass:[UIActivityIndicatorView class]]) {
if (activity.tag == count *100+100+i) {
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fileToSave];
if (!fileExists)
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
dispatch_async(queue, ^{
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
UIImage *image = [[UIImage alloc] initWithData:imageData];
NSData *jpegData = UIImageJPEGRepresentation(image,0.001);
[[NSFileManager defaultManager] createFileAtPath:fileToSave contents:jpegData attributes:nil];
dispatch_sync(dispatch_get_main_queue(), ^{
imgView.image = image;
[activity stopAnimating];
[activity removeFromSuperview];
});
});
}else{
UIImage *image = [UIImage imageWithContentsOfFile:fileToSave];
if(!image) image = [UIImage imageNamed:@"rest-blank-thumbnail.png"];
imgView.image = image;
[activity removeFromSuperview];
}
}
}
}
}
}
}
}
}
-(NSString*) sha1: (NSString *)str
{
const char *cstr = [str cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:str.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, data.length, digest);
NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
[output appendFormat:@"%02x", digest[i]];
return output;
}
- (void)viewDidUnload {
_scrollView1 = nil;
_scrollView2 = nil;
}
- (void)dealloc {
[myCompareImage1 release];
[myCompareImage2 release];
}
最佳答案
如果您打开了“僵尸”(方案诊断),那么实际上不会删除任何内容。因此,在 RAM 较少的设备(如 iPad 1)上,您将很快耗尽内存并收到内存警告。模拟器一般不会有这个问题。
关于即使我正在释放,iPhone 应用程序也会由于收到内存警告而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13156789/
我有一个静态类。 static class AppDirectory { public static string PACSTEMP = Path.Combine(Path.GetTempPa
我已经设置了一个启用了推送通知的 iOS 应用。 我可以将消息推送到应用程序,例如角标(Badge)计数工作并相应更新。 但我从未在锁屏或其他地方看到标准的推送通知弹出窗口,但手机会振动,因此消息会通
我们有一个带有 Web 应用程序和一堆 Windows 服务的系统,它们在做一些后台工作。 每当我们需要对系统进行更实质性的更改时,我们最终不得不发出 IIS 重置,然后手动重新启动所有相关的 Win
我有以下几行 John SMith: A Pedro Smith: B Jonathan B: A John B: B Luis Diaz: A Scarlet Diaz: B 我需要获得所有获得
我正在编写一个 Java 客户端(在 weblogic 10.3 上)来调用一个安全的网络服务。我已获得安装在 cacerts、DemoIdentity.jks 和 DemoTrust,jks 中的客
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎偏离主题,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或 include a mini
我正在尝试调用void方法addToList,该方法将通过用户传递给它的两个字符串除外。我检查了dataSource类,以确保它确实接受了那些作为参数。问题是我在该方法调用上始终收到标识符>预期错误,
我的任务:使用scanner方法从一行数据中提取字符串、 float 和整数。 数据格式为: Random String, 240.5 51603 Another String, 41.6 59087
这个问题已经有答案了: What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? (25 个回答)
首先我实例化一个游戏状态 class GameState extends state{ ArrayList levels; int currentLevelID; public GameState()
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我有一个实现为单例的 Controller 对象,它有一个可以随时驱逐对象的缓存。当一个对象即将被删除时,我想通知任何使用此 Controller 的类,以便它们能够做出适当的响应。我对这种行为的第一
因此,我尝试跨集群发送消息,该消息将包含一个 User 对象,该对象是一个可序列化类。 当我发送 String 或 int 时,它工作正常,消息发送没有问题,并且集群上的所有 channel 都收到它
我试图创建的程序是一个基本游戏,用户输入网格大小,选择 block 接收增加分数的奖品、从分数中夺走分数的强盗或结束游戏的炸弹。我收到堆栈流错误,但我不明白为什么? 抱歉,代码量很大,我只是无法找到问
使用此代码我会得到什么ConcurrentModificationException?我有一个同步(监听器)锁。 private void notifyListeners(MediumRenditio
我想在捕获 DeadlineExceededError 后正确退出。我还剩下多少钱来清理? 例如, try: do_some_work() except DeadlineExceededError
我有 2 个 Intranet 站点: http://intranetv1/ http://intranetv2/ v1基于.NET 1.1,v2基于.NET 3.5 在 v1 上,我创建了一个网页,
我有一个在 Linux 3.12 上运行的 C 程序。该程序产生几个子进程。其中一个进程会生成一个线程,该线程运行一段时间然后终止。当该子进程运行时,它会执行 epoll_wait()。 epoll_
我能够将 APNS 集成到我的应用程序中。现在我想在用户点击它或用户在使用应用程序时收到通知时处理通知。我使用下面的代码在收到通知时显示警报对话框: func application(applicat
当我试图在浏览器上运行这段代码时,出现了以下错误。"错误响应错误代码:501消息:不支持的方法(“POST”)。错误码解释:501-服务器不支持该操作。" 浏览器控制台出现以下错误: "1.加载资源失
我是一名优秀的程序员,十分优秀!