0

我在这里需要一点帮助,我已经通过模态加载了一个视图,基本上我现在正试图关闭这个视图,但是在视图消失后它一直在崩溃。

它说* -[PointInfoController endAppearanceTransition]: message sent to deallocated instance 0x74d5e90

下面是 .H 文件:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

@class PointInfoController;

@protocol PointInfoDelegate
- (void)PointInfoDidFinish:(PointInfoController*)PointInfoController;
@end

@interface PointInfoController : UIViewController <UIScrollViewDelegate>
{
IBOutlet UIScrollView *scrollView;

IBOutlet UIImageView *thumbnailView;

IBOutlet UIButton *Dismiss;

id<PointInfoDelegate> delegate;

}

@property (retain) id<PointInfoDelegate> delegate;

@property (retain, nonatomic) IBOutlet UITextView *description;

@property (retain, nonatomic) IBOutlet UIScrollView *scrollView;

@property (retain, nonatomic) IBOutlet UIImageView *thumbnailView;

- (IBAction)DismissView:(id)sender;


@end

下面是 .M 文件:

#import "PointInfoController.h"
#import "LockOnLocation.h"

@implementation UIScrollView (AutoContentSize)

- (void) setAutosizeContent:(BOOL)autosizeContent {

if (autosizeContent) {
    CGFloat contentWidth =
    self.frame.size.width == self.superview.frame.size.width ?
    self.superview.frame.size.width :
    self.frame.size.width + 10;
    CGFloat contentHeight = 
    self.frame.size.height == self.superview.frame.size.height ?
    self.superview.frame.size.height :
    self.frame.size.height + 164;
    self.contentSize = CGSizeMake(contentWidth, contentHeight);
}
}

@end

@implementation PointInfoController
@synthesize description;
@synthesize scrollView;
@synthesize thumbnailView;
@synthesize delegate;

- (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

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
self.scrollView.delegate = self;

[super viewDidLoad];
}


- (void)viewDidUnload
{
[self setDescription:nil];
[scrollView release];
scrollView = nil;
[self setScrollView:nil];
[self setThumbnailView:nil];
[thumbnailView release];
thumbnailView = nil;
[Dismiss release];
Dismiss = nil;

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

- (IBAction)DismissView:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
[self release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
[description release];
[scrollView release];
[thumbnailView release];
[Dismiss release];
[super dealloc];
}

@end
4

1 回答 1

1

我对这一切都很陌生,我在同一个问题上花了很多天。责备一切,只怪我自己!我发现我无意中释放了引用的实例。就我而言,我已将实例放入 SSLConnectionRef 并 CFRelease 将其放入。我不确定为什么您在查看代码时遇到问题。无论如何,我认为您的编译器会抱怨您的 [instance release] 方法,因为这些方法不再被允许。您遇到问题是因为您和系统都在释放实例。你需要摆脱你的释放,一切都会好起来的。

于 2012-10-17T01:41:55.290 回答