小编use*_*651的帖子

WKWebView 检查 HTML 表单提交

我的任务是将 Objective-C 应用程序转换为完全 Swift 4。该应用程序基本上是一个包含我公司网站的网络浏览器。为了让用户表单抱怨每次输入用户名/密码,应用程序需要检查何时提交 HTML 表单并抓取网站并存储 u/p。

ObjC中有一个方法: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

这使我可以检查表单何时提交:

static NSString * const FORM_USER = @"document.getElementById('sUserID').value";
static NSString * const FORM_PASS = @"document.getElementById('sPassword').value";

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

        //save form data
        if(navigationType == UIWebViewNavigationTypeFormSubmitted) {
            dispatch_async(dispatch_get_main_queue(), ^{
                //grab the data from the page
                NSString *username = [self.webView stringByEvaluatingJavaScriptFromString: FORM_USER];
                NSString *password = [self.webView stringByEvaluatingJavaScriptFromString: FORM_PASS];

                //store values locally in the background
                //.....
            });

        }
        return true;
    }
Run Code Online (Sandbox Code Playgroud)

但我在转换 Swift 4.1 时遇到了麻烦,因为我似乎找不到 …

objective-c ios swift wkwebview swift4

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

PHP str_replace是否有超过13个字符的限制?

直到第13个字符被击中为止.一旦str_ireplace在cyper数组中命中"a",str_ireplace就会停止工作.

数组的大小是否有限制?请记住,如果键入"abgf",我会得到"nots",但如果我输入"abgrf",当我得到"注释"时,我会得到"notrs".我的大脑无法弄明白.

$_cypher = array("n","o","p","q","r","s","t","u","v","w","x","y","z","a","b","c","d","e","f","g","h","i","j","k","l","m");

$_needle = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");


$_decryptedText = str_ireplace($_cypher, $_needle, $_text);
echo $_decryptedText;
Run Code Online (Sandbox Code Playgroud)

救命?

php compiler-errors str-replace

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

UIButton不会在iOS 9.3上显示

我有一个UIButton,它不仅出现在iOS 9.3中.

我不明白为什么.谁能告诉我我做错了什么?

我需要ViewDidAppear方法中的按钮,因为我在设置此按钮后需要放置一些其他布局元素.

iPhone 6 8.1按钮设置位置:{{100,100},{42,42}}

iPhone 6 9.3按钮设置位置:{{0,0},{0,0}}

iPhone 6Plus 8.1按钮设置位置:{{100,100},{42,42}}

iPhone 6Plus 9.3按钮设置位置:{{0,0},{0,0}}

#define MARGIN_SIZE  10
@interface HomeViewController ()
@property (weak, nonatomic) UIButton *btnSettings;
@end


- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    self.btnSettings = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btnSettings.userInteractionEnabled = YES;
    self.btnSettings.frame = CGRectMake(100, 100, 42, 42);
    self.btnSettings.tag = 21;
    [self.btnSettings setImage:[UIImage imageNamed:@"settings_black"] forState:UIControlStateNormal];
    [self.btnSettings addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.btnSettings];

   NSLog(@"Button Settings Location: %@", NSStringFromCGRect(self.btnSettings.frame) );

}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uibutton ios

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

子部分未将样式注入其父刀片布局

我有一个需要一些自定义 js 和样式的部分子视图。这个子视图是整个应用程序中唯一使用它的视图。它很复杂,所以 JS 被分解成它自己的文件。

我试图根据文档将脚本和样式“注入”到父布局中,但它似乎不起作用。我已经厌倦了@parent@@parent部分的组合。我尝试将主要布局更改@yield('scripts') @yield('styles')@section('scripts')@show.

我错过了什么?这甚至可能吗?

main.blade.php (为简洁起见缩短)

<head>
    @include('apps.includes.styles')

    @yield('styles')//a place for custom style
</head>
<body>
@yield('content')

@include('apps.includes.scripts')
@yield('scripts') //a place for custom scripts
</body>
Run Code Online (Sandbox Code Playgroud)

创建.blade.php

@extends('layouts.main')
@section('styles')@endsection
@section('scripts')@endsection
@section('content')
    <div>
      @include('partials._toolbar')
    </div>
@endsection
Run Code Online (Sandbox Code Playgroud)

_toolbar.blade.php

@section('styles')
    @parent
    <script src="{{asset('assets/css/mystyle.css')}}"></script>
@endsection

@section('scripts')
    @parent
    <script src="{{asset('assets/js/myjs.js')}}"></script>
@endsection

<section>
// my toolbar html code
</section>
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-blade laravel-6

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