Jos*_*vis 6 iphone xcode uiwebview ios cordova
我不知道任何Objective-C,这就是我使用PhoneGap创建iOS应用程序的原因.PhoneGap for iOS存在一个很大的缺陷.键盘不断有形式助手("下一个","上一个"和"完成"按钮.)网上关于如何摆脱这一点的信息非常少,所有关于它的Stackoverflow问题都说它实际上是不可能.但过了一会儿我偶然发现了这个教程.底部段落告诉您如何做到这一点.它工作,我下载并测试完成的应用程序.
但由于我不知道如何在Xcode或Objective-C中做任何事情,我不知道代码的两个部分是什么文件,他在教程中没有说.
任何人都可以告诉我PhoneGap应用程序文件中的位置吗?我很欣赏它,这一直困扰着我.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
还有这个
RichTextEditorViewController *viewController = [[RichTextEditorViewController alloc] initWithNibName:@"RichTextEditorViewController" bundle:nil];
self.viewController = [[UINavigationController alloc] initWithRootViewController:viewController];
Run Code Online (Sandbox Code Playgroud)
还有这个
- (void)removeBar {
// Locate non-UIWindow.
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]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
Nic*_*247 16
我自己也想过要这样做.我是IOS开发人员,但需要使用phonegap来降低多平台开发人员的成本.
无论如何,我修复了你的代码.因为,我想,你不想花时间学习obj-c,你只需要用以下内容替换MainViewController.m的内容:
#import "MainViewController.h"
@implementation MainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
- (void) removeBar {
// Locate non-UIWindow.
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]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}
- (void)keyboardWillShow:(NSNotification*) notification {
// remove the bar in the next runloop (not actually created at this point)
[self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
}
@end
Run Code Online (Sandbox Code Playgroud)
作为一个警告,这是一个hacky解决方案(但是使用phonegap也是如此!),并且可能会在iOS的未来版本中出现问题.但我想我们会解决这个问题......
| 归档时间: |
|
| 查看次数: |
3680 次 |
| 最近记录: |