2013

Mar

20

iOS开发之UIWebView自定义网页中的alert和confirm提示框风格
文章分类:iOS开发
@interface UIWebView (JavaScriptAlert)

- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
- (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;

@end

@implementation UIWebView (JavaScriptAlert)

static BOOL diagStat = NO;

- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"
                                                          message:message
                                                         delegate:nil
                                                cancelButtonTitle:@"确定"
                                                otherButtonTitles:nil];
    [alertView show];
    [alertView release];
}

- (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"
                                                          message:message
                                                         delegate:self
                                                cancelButtonTitle:@"取消"
                                                otherButtonTitles:@"确定", nil];
    [alertView show];
    
    while (alertView.hidden == NO && alertView.superview != nil) {
        [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01f]];
    }
    
    [alertView release];
    
    return diagStat;
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        diagStat = NO;
    } else if (buttonIndex == 1) {
        diagStat = YES;
    }
}

@end

相关文章

error: C compiler cannot create executables错误的解决方法 (2012-03-01)

iOS开发之对象序列化和反序列化 (2012-03-21)

iOS中后台运行 (2012-04-01)

iOS开发之使用lipo命令制作模拟器与真机通用静态库 (2012-04-27)

iOS开发之使用UIGestureRecognizer (2012-05-02)

iOS开发之使用PresentModalViewController (2012-07-04)

iOS开发之self.abc = nil与[_abc release]的区别 (2012-09-20)

iOS开发之App自定义URL Scheme (2012-10-24)

Xcode4.5新语法,碉堡了 (2012-11-30)

iOS开发之使用TestFlight进行企业部署 (2013-03-12)

看看他们的脚印

闲言碎语

突然发现,又是一年 (6月6日)

很久没来看博客了,发现头像又不能显示。。。 (3月28日)

FedEx真是龟速! (8月27日)

文章分类

最近文章

I'M BACK

让iOS App通过iTunes进行文...

生活不容易,何必呢

清除Linux系统中/var/spoo...

iOS开发之UIWebView自定义网...

最近评论

日志归档

友情链接

其它功能

随机标签