0
프로그래밍 방식으로 뷰 컨트롤러를 밀고 WebView 및 사용자 정의 직사각형 둥근 버튼을 오른쪽 아래 왼쪽 구석에 뷰에 밀어 넣었습니다.푸시보기 컨트롤러에서 맞춤 뒤로 버튼 클릭 이벤트
-(void)loadView {
CGRect frame = CGRectMake(0.0, 0.0, 480, 320);
WebView = [[[UIWebView alloc] initWithFrame:frame] autorelease];
WebView.backgroundColor = [UIColor whiteColor];
WebView.scalesPageToFit = YES;
WebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin);
WebView.autoresizesSubviews = YES;
WebView.exclusiveTouch = YES;
WebView.clearsContextBeforeDrawing = YES;
self.roundedButtonType = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
self.roundedButtonType.frame = CGRectMake(416.0, 270.0, 44, 19);
[self.roundedButtonType setTitle:@"Back" forState:UIControlStateNormal];
self.roundedButtonType.backgroundColor = [UIColor grayColor];
[self.roundedButtonType addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
self.view = WebView;
[self.view addSubview: self.roundedButtonType ];
[WebView release];
}
내비게이션의 뒤로 버튼으로 추가 한 동작입니다. EXC_BAD_ACCESS 메시지 : 뒤로 버튼 다음 이전 뷰를 보여주고 클릭하지만 응용 프로그램이 해당 뷰에 갇혀와 GDB는 프로그램이 신호를받은 보여주고있어 여기
-(void)back:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
-(void)viewDidUnload{
self.WebView = nil;
self.roundedButtonType = nil;
}
-(void)dealloc{
[roundedButtonType release];
[super dealloc];
}
.
이 문제를 어떻게 해결합니까?
WebView = [[[UIWebView alloc] initWithFrame:frame] autorelease];
하지만 당신에게 -release
를 다시를 : 당신은 -autorelease
이
감사합니다,
감사합니다, Kenny WebView에 autorelease 중 하나를 제거했으며 그 경우에는 문제가 없습니다. [WebView release]가 http 요청을 해제하거나 WebView에서 데이터를 언로드하고 URL에 대한 연결이 활성화되어 있습니까? 할당하기 전에 설정 프레임과 제목도 알아 보겠습니다. Thasnk – TechFusion
@Tech : 웹보기가 '-dealloc'되었을 때 웹보기가 소유 한 모든 항목이'-release'됩니다 (release ≠ deallocate를 기록하십시오). 귀하의 경우'self'는'self.view'에 지정할 때 웹보기를'-retain' 할 것이므로'-release''ing하면 연결을 죽이지 않습니다. – kennytm
Hello Kenny, ViewDidUnload()에서도 self.WebView = nil을 만들고 있습니다. 그래서 내가 dealloc 작업에 다음을 추가해야 연결을 죽일? - (void) dealloc { [super dealloc] [self.WebView dealloc] // 맞습니까? } 감사합니다. – TechFusion