因此,从 UIWebView 中的这个线程UIKeyboardAppearance和TomSwift 的精彩答案改编代码,我得到了大约 99% 的工作。
在 iOS 7 模拟器中,一切似乎都运行良好。但是在 iOS 8 中,当键盘第一次出现时,< > 完成栏是白色的。当我点击或选择另一个输入时,它会更改为我指定的颜色。
我的问题是,我怎样才能防止和/或改变那个白色部分?

另一个线程中的所有代码都是相同的,除了我在 keyboardWillAppear 中这样调用的颜色。
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual : [UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {
if ([[possibleFormView description] hasPrefix : @"<UIInputSetContainerView"]) {
for (UIView* peripheralView in possibleFormView.subviews) {
peripheralView.backgroundColor = [UIColor colorWithRed:0.271 green:0.271 blue:0.271 …Run Code Online (Sandbox Code Playgroud) 因此,经过谷歌和SO的长时间搜索,我没有发现类似的问题.有些人接近但不像我的.
手头的问题:在我的应用程序(基于WKWebView)中,如果显示键盘,我双击主页并切换到显示键盘的另一个应用程序,我的应用程序键盘被隐藏.这不是问题.因此,当我再次执行多任务时,在我的应用程序的快照中,键盘消失了,但我上面的自定义工具栏似乎保持不变,下面没有键盘.我点按我的应用程序,它会动画,然后返回到屏幕底部.
我尝试过的:我知道[self.view endEditing:YES],resigningFirstResponder以及关闭键盘的所有方法.尝试通过viewWillDisappear,applicationWillResignActive和applicationDidEnterBackground进行放置和混合.这些都不会处理我的工具栏问题.
这就是我在屏幕上和屏幕上设置键盘动画的方式,同时保持工具栏可见.
- (void)keyboardWillShow:(NSNotification*)notification
{
NSDictionary* info = [notification userInfo];
NSNumber *durationValue = info[UIKeyboardAnimationDurationUserInfoKey];
NSNumber *curveValue = info[UIKeyboardAnimationCurveUserInfoKey];
NSValue *endFrame = info[UIKeyboardFrameEndUserInfoKey];
[UIView animateWithDuration:durationValue.doubleValue
delay:0
options:(curveValue.intValue << 16)
animations:^{
self.toolBar.frame = CGRectMake(0,
[endFrame CGRectValue].origin.y - self.toolBar.bounds.size.height+44,
self.toolBar.bounds.size.width,
self.toolBar.bounds.size.height);
}
completion:nil];
}
- (void)keyboardWillHide:(NSNotification*)notification
{
NSDictionary* info = [notification userInfo];
NSNumber *durationValue = info[UIKeyboardAnimationDurationUserInfoKey];
NSNumber *curveValue = info[UIKeyboardAnimationCurveUserInfoKey];
NSValue *endFrame = info[UIKeyboardFrameEndUserInfoKey];
[UIView animateWithDuration:durationValue.doubleValue
delay:0
options:(curveValue.intValue << 16)
animations:^{
self.toolBar.frame = CGRectMake(0,
[endFrame CGRectValue].origin.y - self.toolBar.bounds.size.height,
self.toolBar.bounds.size.width,
self.toolBar.bounds.size.height); …Run Code Online (Sandbox Code Playgroud) 所以我正在将我的UIWebView应用程序转换为WKWebView只是为了发现它不会打开外部网站,即dropbox,facebook等.
它在viewDidLoad中加载我的网站,所以这不是问题.
例:
NSURL *nsurl=[NSURL URLWithString:@"example.com"];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webView loadRequest:nsrequest];
webView.navigationDelegate = self;
webView.UIDelegate = self;
[self.view addSubview:webView];
Run Code Online (Sandbox Code Playgroud)
我打过电话:
-(void)webView:(WKWebView *)webView didStartProvisionalNavigation: (WKNavigation *)navigation {}
- (void)webView:(WKWebView *)webView didFinishNavigation: (WKNavigation *)navigation{}
Run Code Online (Sandbox Code Playgroud)
随着:
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {}
decisionHandler(WKNavigationActionPolicyAllow);
Run Code Online (Sandbox Code Playgroud)
最后在我的info.plist中我添加了:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
Run Code Online (Sandbox Code Playgroud)
但没有任何作用.我究竟做错了什么?
任何帮助都将一如既往地受到高度赞赏.
我正在将我的应用程序从UIWebView迁移到WKWebView.一切顺利,我正在努力修补它.但是,我现在注意到我无法下载论坛附件.
我正在使用HCDownload,到目前为止我一直都很完美,所以我知道它不是为了这个目的.我相信它的要求,但我无法弄明白.
我知道以下内容:
UIWebView => WKWebView Equivalent
--------------------------------------------------------------
didFailLoadWithError => didFailNavigation
webViewDidFinishLoad => didFinishNavigation
webViewDidStartLoad => didStartProvisionalNavigation
shouldStartLoadWithRequest => decidePolicyForNavigationAction
Run Code Online (Sandbox Code Playgroud)
所以我知道我在下面尝试:
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
NSURLRequest *request = navigationAction.request;
NSURL *fileURl = [request URL];
NSString *externalFileExtension = [fileURl pathExtension];
NSString *internalFileExtension = [[fileURl absoluteString] pathExtension];
HCDownloadViewController *dlvc = [[HCDownloadViewController alloc] init];
UINavigationController *vc = [[UINavigationController alloc] initWithRootViewController:dlvc];
dlvc.delegate = self;
vc.transitioningDelegate = self;
if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {
//External file extensions
if ([fileExtensions containsObject:[externalFileExtension lowercaseString]]) { …Run Code Online (Sandbox Code Playgroud) 到目前为止,我已经设法从我的表视图中删除行,但它不会在给定的Documents文件夹中更新.我怎么做到这一点?下面是我正在使用的代码.
我试图从这里实现代码如何从放在文档文件夹中的文件夹中删除文件.
我的目标是能够删除任何文件,而不仅仅是所需的文件.
提前致谢.
#import "Documents.h"
@interface DocumentsViewController ()
@end
@implementation DocumentsViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.navigationItem.rightBarButtonItem = self.editButtonItem;
NSString *temp = [[NSBundle mainBundle] resourcePath];
self.directoryPath = [temp …Run Code Online (Sandbox Code Playgroud) ios ×5
webview ×2
wkwebview ×2
appearance ×1
download ×1
keyboard ×1
navigation ×1
objective-c ×1
tableview ×1
uitoolbar ×1
url ×1
web ×1