我正在尝试将一个webview嵌入到navController中,但最终导致webview根本无法滚动。
网页无论其大小如何都不允许滚动。我在这里做错了什么?
using Foundation;
using UIKit;
using System.Drawing;
namespace TestNamespace
{
public class Level2ViewController : UIViewController
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
Title = "Test";
UIWebView webview = new UIWebView (View.Bounds);
View.AddSubview(webview);
webview.LoadRequest (new NSUrlRequest (new NSUrl("https://news.google.com/")));
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
}
}
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
UINavigationController navController;
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
window = new UIWindow ();
window.MakeKeyAndVisible ();
navController = new UINavigationController ();
Level2ViewController new1 = new Level2ViewController();
// push the view controller onto the nav controller and show the window
navController.PushViewController(new1, false);
window.RootViewController = navController;
window.MakeKeyAndVisible ();
return true;
}
public override void OnResignActivation (UIApplication application)
{
// Invoked when the application is about to move from active to inactive state.
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
// or when the user quits the application and it begins the transition to the background state.
// Games should use this method to pause the game.
}
public override void DidEnterBackground (UIApplication application)
{
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
}
public override void WillEnterForeground (UIApplication application)
{
// Called as part of the transiton from background to active state.
// Here you can undo many of the changes made on entering the background.
}
public override void OnActivated (UIApplication application)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive.
// If the application was previously in the background, optionally refresh the user interface.
}
public override void WillTerminate (UIApplication application)
{
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
}
}
}
答案 0 :(得分:0)
在ViewDidLoad
中写下此内容webiew.ScrollView.ScrollEnabled = true;
webView.ScalesPageToFit = true;