Je suis nouveau sur ces forums alors je m'excuse pour mon absence. J'ai fait une recherche aussi approfondie que possible, mais je n'ai pas pu trouver quelqu'un d'autre avec ce problème, applogiser si cela a été couvert ailleurs.Pourquoi mon interface UIWebView n'autorise-t-elle pas l'interaction utilisateur?
J'ai créé un exemple très simple de mon problème. Je suis sûr qu'il me manque quelque chose mais je ne peux pas pour la vie de moi comprendre quoi.
Je crée un UIWebView et l'ajoute à un contrôleur de vue personnalisé qui hérite de UIViewController. Lorsque l'application est chargée dans le simulateur d'iPad, uiwebview charge la page souhaitée, mais UIWebView ne répond pas du tout. Le webview ne fait pas de panoramique ou de défilement et aucun des liens dans la page ne peut être cliqué. Cependant, si vous changez l'orientation de la webdirectory, tout fonctionne.
Merci d'avance pour votre aide !!
AppDelegate tête
#import <UIKit/UIKit.h>
#import "EditorViewController.h"
@interface FixEditorTestAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
EditorViewController *editorView;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) EditorViewController *editorView;
@end
AppDelegate mise en œuvre
#import "FixEditorTestAppDelegate.h"
#import "EditorViewController.h"
@implementation FixEditorTestAppDelegate
@synthesize window;
@synthesize editorView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"application is loading");
editorView = [[EditorViewController alloc] init];
[window addSubview:[editorView view]];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[window release];
[editorView release];
[super dealloc];
}
@end
Voir d'en-tête
Controller
#import <UIKit/UIKit.h>
@interface EditorViewController : UIViewController <UIWebViewDelegate> {
UIWebView *webView;
}
@property (nonatomic, retain) UIWebView *webView;
@end
View Controller Application
#import "EditorViewController.h"
@implementation EditorViewController
@synthesize webView;
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
NSLog(@"loadView called");
UIView *curView = [[UIView alloc] init];
webView = [[UIWebView alloc] init];
webView.frame = CGRectMake(20, 40, 728, 964);
webView.delegate = self;
webView.backgroundColor = [UIColor redColor];
[curView addSubview: webView];
self.view = curView;
[curView release];
}
//Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad called");
NSURL *url = [[NSURL alloc] initWithString:@"http://www.nytimes.com"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[webView loadRequest:request];
[url autorelease];
[request release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}
- (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.
}
- (void)viewDidUnload {
webView.delegate = nil;
[webView release];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
Merci, j'aurais pensé que c'était aussi le problème, mais ce n'est pas le cas. J'avais essayé userInteractionEnabled mais cela ne semble pas avoir d'effet. – thomasmcgee
PS. Je peux l'obtenir à partir d'une plume sans aucun problème, mais j'espère comprendre pourquoi je ne peux pas le faire fonctionner par programmation. – thomasmcgee