UIAlertview中自定义ALert, confirm, promopt
来源:互联网 发布:windows android语言 编辑:程序博客网 时间:2024/05/19 21:44
js中有 ALert confirm 和promopt 三种 类似ios本地的 UIAlertview 样子
但是在 ios native 的app 中 弹出的话alert 的title 是 url 的地址,比较丑
为了美观,我们要加入以下的方法。
- #import <UIKit/UIKit.h>
- @interface UIWebView (JavaScriptAlert)
- -(void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
- -(BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
- @end
- #import "UIWebView+JavaScriptAlert.h"
- @implementation UIWebView (JavaScriptAlert)
- static BOOL diagStat = NO;
- -(void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame{
- UIAlertView* dialogue = [[UIAlertView alloc]initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
- [dialogue show];
- [dialogue autorelease];
- }
- -(BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame{
- UIAlertView* dialogue = [[UIAlertView alloc] initWithTitle:nil message:message delegate:self cancelButtonTitle:NSLocalizedString(@"Okay", @"Okay") otherButtonTitles:NSLocalizedString(@"Cancel", @"Cancel"), nil];
- [dialogue show];
- while (dialogue.hidden==NO && dialogue.superview!=nil) {
- [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01f]];
- }
- [dialogue release];
- return diagStat;
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
- if (buttonIndex==0) {
- diagStat=YES;
- }else if(buttonIndex==1){
- diagStat=NO;
- }
- }
- @end
0 0
- UIAlertview中自定义ALert, confirm, promopt
- 自定义alert和confirm
- bootstrap 自定义alert 和 confirm
- javascript 中confirm alert 换行
- [原创]使用自定义的alert和confirm
- jquery自定义对话框alert、confirm和prompt
- jquery自定义对话框alert、confirm和prompt
- jquery-confirm自定义alert插件,alert显示内容可以换行
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- JS中confirm,alert,prompt函数
- javascript中confirm,alert,ptompt的用法
- JavaScript中confirm,alert,prompt的用法
- JS中confirm,alert,prompt函数
- JS中confirm,alert,prompt函数
- JS中confirm,alert,prompt函数
- pthreads 安装error: pthreads requires ZTS,please re-compile PHP with ZTS enabled
- 将文字显示在图片上面,并使文字背景半透明
- jquery获取颜色,ie和ff的区别
- 【C++专题】static_cast, dynamic_cast, const_cast探讨
- ibatis返回List<String>
- UIAlertview中自定义ALert, confirm, promopt
- Can't load AMD 64-bit .dll on a IA 32-bit platform
- linux下vi命令大全
- Oracle创建表空间和表空间用户的步骤
- 测试
- cocos2d-x使用CCControlButton的一些问题
- WinCE获取系统语言
- SQL 语句获取表字段名称,属性
- gearman