我有一个付款html页面,我在iOS应用程序的webview中加载。 当点击表单中的提交按钮时,我想在Objective C中编写一些代码。 我知道我们可以使用这样的导航类型来检测点击,但这不起作用:
void CConfigurationApp::FindMenuOptions()
{
BOOL bOK = TRUE;
CString Level0;
CString Level1;
CString Level2;
CString Level3;
CString Level4;
long MenuID = 0;
long LevelNo;
int l0;
int l1;
int l2;
int l3;
int l4;
int NoItems0;
int NoItems1;
int NoItems2;
int NoItems3;
int NoItems4;
CString csText;
CString Name;
CString Handle;
long ResourceID;
UINT state;
CWnd* pMain;
CMenu* pMenu;
pMenu = new CMenu;
// Get Main Menu
pMain = AfxGetMainWnd();
if (pMain != NULL)
{
// Get the main window's menu
pMenu = pMain->GetMenu();
}
for (l0 = 0; l0 < pMenu->GetMenuItemCount(); ++l0)
{
pMenu->GetMenuString(l0, csText, MF_BYPOSITION);
CMenu* pSubMenu1 = pMenu->GetSubMenu(l0);
++MenuID;
LevelNo = 0;
Level0 = csText;
Level1 = "";
Level2 = "";
Level3 = "";
Level4 = "";
NoItems0 = pSubMenu1->GetMenuItemCount();
if (NoItems0 < 0)
NoItems0 = 0;
Name = "";
Handle = "";
ResourceID = 0;
AddIntoMenuArray(MenuID, LevelNo, Level0, Level1, Level2, Level3, Level4, NoItems0, Name, Handle, ResourceID);
for (l1 = 0; l1 < NoItems0; ++l1)
{
pSubMenu1->GetMenuString(l1, csText, MF_BYPOSITION);
CMenu* pSubMenu2 = pSubMenu1->GetSubMenu(l1);
++MenuID;
LevelNo = 1;
Level1 = csText;
Level2 = "";
Level3 = "";
Level4 = "";
NoItems1 = pSubMenu2->GetMenuItemCount();
if (NoItems1 < 0)
NoItems1 = 0;
Name = "";
Handle = "";
ResourceID = 0;
AddIntoMenuArray(MenuID, LevelNo, Level0, Level1, Level2, Level3, Level4, NoItems1, Name, Handle, ResourceID);
for (l2 = 0; l2 < NoItems1; ++l2)
{
pSubMenu2->GetMenuString(l2, csText, MF_BYPOSITION);
CMenu* pSubMenu3 = pMenu->GetSubMenu(l2);
++MenuID;
LevelNo = 2;
Level2 = csText;
Level3 = "";
Level4 = "";
NoItems2 = pSubMenu3->GetMenuItemCount();
if (NoItems2 < 0)
NoItems2 = 0;
Name = "";
Handle = "";
ResourceID = 0;
AddIntoMenuArray(MenuID, LevelNo, Level0, Level1, Level2, Level3, Level4, NoItems2, Name, Handle, ResourceID);
for (l3 = 0; l3 < NoItems2; ++l3)
{
pSubMenu3->GetMenuString(l3, csText, MF_BYPOSITION);
CMenu* pSubMenu4 = pMenu->GetSubMenu(l3);
++MenuID;
LevelNo = 3;
Level3 = csText;
Level4 = "";
NoItems3 = pSubMenu3->GetMenuItemCount();
if (NoItems3 < 0)
NoItems3 = 0;
Name = "";
Handle = "";
ResourceID = 0;
AddIntoMenuArray(MenuID, LevelNo, Level0, Level1, Level2, Level3, Level4, NoItems3, Name, Handle, ResourceID);
for (l4 = 0; l4 < NoItems3; ++l4)
{
pSubMenu4->GetMenuString(l4, csText, MF_BYPOSITION);
++MenuID;
LevelNo = 4;
Level4 = csText;
NoItems4 = 0;
Name = "";
Handle = "";
ResourceID = 0;
AddIntoMenuArray(MenuID, LevelNo, Level0, Level1, Level2, Level3, Level4, NoItems4, Name, Handle, ResourceID);
}
}
}
}
}
DeleteMenuArray();
delete pMenu;
如果我们能以任何其他方式做到,请告诉我。
答案 0 :(得分:0)
首先你需要设置UIWebViewDelegate方法,我给你提供示例导航代码。你需要在这里自定义。
#pragma mark - UIWebView Delgate Method
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
switch (navigationType)
{
case UIWebViewNavigationTypeLinkClicked:
//When User tapped a link.
break;
case UIWebViewNavigationTypeOther:
//Some other action occurred.
break;
case UIWebViewNavigationTypeFormSubmitted:
//user submitted a form.
break;
case UIWebViewNavigationTypeBackForward:
//User tapped the back or forward button. .
break;
case UIWebViewNavigationTypeReload:
//User tapped the reload button.
break;
case UIWebViewNavigationTypeFormResubmitted
//User resubmitted a form. .
break;
}
return YES;
}