小编Har*_*pta的帖子

URISyntaxException 查询中的非法字符

我正在尝试在默认浏览器中打开一个链接。我使用了以下代码。

String myUrl = "http://www.example.com/engine/myProcessor.jsp?Type=A Type&Name=1100110&Char=!"; 

        try {
            Desktop.getDesktop().browse(new URI(myUrl));
        } catch (IOException err) {
            setTxtOutput("Error: "+err.getMessage());
        } catch (URISyntaxException err) {      
            setTxtOutput("Error: "+err.getMessage());
        } catch (Exception err) {
            setTxtOutput("Error: "+err.getMessage());
        }
Run Code Online (Sandbox Code Playgroud)

我在索引处的查询中收到URISyntaxException非法字符

我认为这是因为诸如? , &! 在我的网址中。我尝试使用:

URLEncoder.encode(myUrl, "UTF-8");
Run Code Online (Sandbox Code Playgroud)

但这给了我另一个错误。

Failed to open http%3A%2F%2Fwww.example.com%2F........... 
The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

请您告诉我如何更正URISyntaxException 非法字符错误。

java uri

10
推荐指数
2
解决办法
4万
查看次数

如何解雇iOS Decimal键盘?

我正在制作一个iOS应用程序,要求用户为多个文本字段输入数值.在UITextField属性下,我使用过

键盘 =十进制键盘

返回键 =完成

键盘占用空间并隐藏"提交表单"按钮.

UIViewController.h文件下,我为每个UITextField编写了以下代码,其中事件为已结束退出:

-(IBAction)dismissKeyboard:(id)sender;
Run Code Online (Sandbox Code Playgroud)

UIViewController.m文件下,我为每个UITextField编写了以下代码:

-(IBAction)dismissKeyboard:(id)sender {

    [textField becomeFirstResponder];
    [textField resignFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)

当我为Xcode 5打开iOS模拟器时,我在屏幕键盘上没有任何DONE字段.但是,如果我从MacBook键盘按RETURN键,屏幕键盘就会消失.

我怎么能够 -

  • 在iOS键盘上显示DONE键?
  • 关掉键盘?

iphone keyboard xcode objective-c ios

5
推荐指数
2
解决办法
3446
查看次数

在Swift 3中从Custom UITableViewCell中检测UIButton

我有一个自定义的UITableViewCell,我使用Interface Builder连接了我的UIButton

@IBOutlet var myButton: UIButton!
Run Code Online (Sandbox Code Playgroud)

在UITableViewController的单元配置下,我有以下代码:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

var customCell = tableView.dequeueReusableCell(withIdentifier: self.MY_CELL_IDENTIFIER, for: indexPath) as! myCustomCell

// CONFIGURE OTHER CELL PARAMETERS

customCell.myButton.tag = indexPath.row

customCell.myButton.addTarget(self, action: #selector(myButtonPressed), for: UIControlEvents.touchUpInside)

return customCell

}
Run Code Online (Sandbox Code Playgroud)

最后,我有

private func myButtonPressed(sender: UIButton!) {
        let row = sender.tag
        print("Button Sender row: \(row)")            
    }
Run Code Online (Sandbox Code Playgroud)

除非我将函数定义更改为以下内容,否则此代码无效:

@objc private func myButtonPressed(sender: UIButton!) {
            let row = sender.tag
            print("Button Sender row: \(row)")

        }
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法在Swift 3中的自定义UITableViewCell上实现UIButton

xcode ios swift

1
推荐指数
1
解决办法
1961
查看次数

标签 统计

ios ×2

xcode ×2

iphone ×1

java ×1

keyboard ×1

objective-c ×1

swift ×1

uri ×1