我遇到了一個問題 - 在試圖設置UIWebView.delegate = self時,我得到了EXC_BAD_ACCESS;UIWebView委託中的EXC_BAD_ACCESS
我的代碼:
vkLogin.h -
#import UIKit/UIKit.h
@interface vkLogin : UIViewController <UIWebViewDelegate>
{
UIWebView *authBrowser;
UIActivityIndicatorView *activityIndicator;
}
@property (nonatomic, retain) UIWebView *authBrowser;
@property (nonatomic, retain) UIActivityIndicatorView *activityIndicator;
@end
vkLogin.m -
#import "vkLogin.h"
#import "bteamViewController.h"
@implementation vkLogin
@synthesize authBrowser;
- (void) viewDidLoad
{
[super viewDidLoad];
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center = CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2);
activityIndicator.autoresizesSubviews = YES;
activityIndicator.hidesWhenStopped = YES;
[self.view addSubview: activityIndicator];
[activityIndicator startAnimating];
authBrowser = [[UIWebView alloc] initWithFrame:self.view.bounds];
authBrowser.delegate = self;
authBrowser.scalesPageToFit = YES;
[self.view addSubview:authBrowser];
NSString *authLink = @"http://api.vk.com/oauth/authorize?client_id=-&scope=audio&redirect_uri=http://api.vk.com/blank.html&display=touch&response_type=token";
NSURL *url = [NSURL URLWithString:authLink];
[authBrowser loadRequest:[NSURLRequest requestWithURL:url]];
}
- (void) webViewDidFinishLoad:(UIWebView *)authBrowser
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Lol" message:@"OLOLO" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
[alert show];
}
@end
所以,如果我commeting委託串 - 一切工作正常,但我沒有收不到我的webViewDidFinishLoad事件。
我在做什麼錯了?
除了問題之外,恭喜你成爲100,000個客觀標記問題! – TheAmateurProgrammer
以這種方式指定'authlink'並重試:'NSString * authLink = @「http://api.vk.com/oauth/authorize?client_id=-&scope=audio&redirect_uri=http://api.vk.com/blank .html&display = touch&response_type = token「;' – Adam
我建議編輯你的方案並打開殭屍對象。它很可能提供有關錯誤訪問內容的更好信息。 –