UIAlertView

- (void)openWeiXin

{

    //判断是否安装了微信

    weiXinURL = [WXApigetWXAppInstallUrl];

    BOOL isInstalled = [MHWeiXin checkWeiXinInstalled:&weiXinURL];

    if (isInstalled)

    {

        [MHWeiXin sendTitle:@"掌上百科"

                   subTitle:nil

                   andImage:[UIImage imageNamed:@"icon.png"]

                      scene:WXSceneSession

                   complete:nil];

    }

    else

    {

        UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"提示"

                                                            message:@"微信未安装,是否前往App Store下载安装"

                                                           delegate:self //这里不设置self的话下面的函数就不调用

                                                  cancelButtonTitle:@"取消"

                                                  otherButtonTitles:@"安装", nil];

        errorAlert.tag = 100;

        [errorAlert show];

        [errorAlert release];

    }

}

 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    if (alertView.tag == 100)

    {

        NSString  *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];

        

        if ([buttonTitle isEqualToString:@"安装"])

        {

            [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:weiXinURL]];

        }

        

        if ([buttonTitle isEqualToString:@"取消"])

        {

            

        }

    }

}

 
posted @ 2012-12-13 10:03  六界剑仙  阅读(104)  评论(0)    收藏  举报