【问题标题】:How to hide the InputAccessoryView of a UIWebView on xamarin.ios/monotouch?如何在 xamarin.ios/monotouch 上隐藏 UIWebView 的 InputAccessoryView?
【发布时间】:2013-08-14 04:44:38
【问题描述】:

是否有隐藏或替换 Xamarin.ios/monotouch 上 UIWebView 的 InputAccessoryView 的方法?

【问题讨论】:

    标签: c# ios uiwebview xamarin.ios xamarin


    【解决方案1】:

    认为你的意思是 MonoTouch.DialogHtmlElement 的单元格附件。这种灵活性似乎没有包含在实施中,但很容易添加。

    转到: MonoTouch.Dialog Github Source (Elements.cs)

    复制 HtmlElement 类定义(撰写本文时的第 527 到 640 行)并将其重命名为 WhatYouWantElement。修改GetCell方法:

    public override UITableViewCell GetCell (UITableView tv)
    {
    ...
    static NSString hkey = new NSString ("WhateverYouWantElement"); //very important to set a unique cell reuse identifier here!
    ...
    cell.Accessory = UITableViewCellAccessory.None;
    ...
    }
    

    这将创建一个没有披露指示符的单元格。重用标识符将确保与内置的 HtmlElement 没有冲突。

    【讨论】:

      【解决方案2】:

      您是否尝试过创建UIWebView 的子类并覆盖其InputAccessoryView 属性使其返回null

      private class CustomWebView : UIWebView
     
      {
            
          public override UIView InputAccessoryView
    
          {
                
              get
                  
              {
                    
                  return null;
                
              }
            
          }
        
      }
     
      
      public override void ViewDidLoad()
 
      {
            
          base.ViewDidLoad();

          // Perform any additional setup after loading the view, typically from a nib.            
        RectangleF frame = new RectangleF(0, 0, 200, 30);
            
            
      
          UITextField txfTest = new UITextField();
            
          txfTest.Frame = frame;
            
          txfTest.BorderStyle = UITextBorderStyle.RoundedRect;
            
          txfTest.Placeholder = "Click here";
            
          txfTest.EditingDidBegin += (object sender, EventArgs e) => {
                    
              // do something
            
          };
      
          CustomWebView webView = new CustomWebView();
            
          webView.LoadRequest(new NSUrlRequest(new NSUrl(@"http://google.com")));
            
          webView.Frame = new RectangleF(0, 100, 320, 480);
            
            
          webView.AddSubview(txfTest);            
            
      
          this.View.AddSubview(webView);
        
      }
      

      我尝试将UITextField 添加到UIWebView,但在聚焦UITextField 后未显示输入附件。我正在使用 iPhone 模拟器 6.1。

      【讨论】:

        猜你喜欢
        • 2012-01-23
        • 1970-01-01
        • 1970-01-01
        • 2012-09-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多