现在的位置: 首页 > 综合 > 正文

IOS 7 自定义的UIAlertView不能在iOS7上正常显示

2014年02月25日 ⁄ 综合 ⁄ 共 1405字 ⁄ 字号 评论关闭

众所周知,当伟大的iOS7系统发布后,表扬的一堆、谩骂的也一片,而对于我们程序员来说最关心的莫过于低版本系统上的程序在搞版本系统上的兼容性问题了。

在iOS6.1几之前,当我们想要做一些提醒用户或临时获取一些数据时,通常会弹出一个模态试图,给予用户提醒,而最常见的做法莫过于直接用UIAlertView添加控件或继承UIAlertView,然后添加自己想要的控件,如:在执行网络连接  下载等耗时任务时我们会弹出一个view  然后显示一个指示器,具体做法:

-
(
IBAction)showTraditionAlert:(id)sender
{
     
    UIAlertView
*alertView = [[UIAlertView alloc]initWithTitle:@
"正在下载....." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",
nil];
    alertView.delegate
=
self;
    [alertView
show];
}
 
 
 
#pragma
mark -- UIAlertViewDelegate
 
//实现代理增加网络指示器
-
(
void)willPresentAlertView:(UIAlertView
*)alertView;{
    indicator
= [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    indicator.frame
= CGRectMake(110, 20, 50, 50);
     
    [alertView
addSubview:indicator];
    [indicator
startAnimating];
    [indicator
release];
}
 
-
(
void)alertView:(UIAlertView
*)alertView clickedButtonAtIndex:(
NSInteger)buttonIndex{
    [indicator
stopAnimating];
}

 

但上面的做法到了iOS7上就没有用了 ,你自己所添加的控件根本显示不出来,也就是说在iOS7上不允许我们更改系统的UIAlertView了(至少目前是这样2013/07/18 beta3版本),我想大家肯定也遇到了这样的问题,那现在改怎么半呢? 可以采用UIWindow的方式实现具体做法网上很多,我比较懒 随便写了点

//
// 
CustomizedAlertAnimation.h
// 
AlertAnimationDemo
//
// 
Created by PSH_Chen_Tao on 7/18/13.
// 
Copyright (c) 2013 wolfman. All rights reserved.
//
 
 
//这个类主要时用来对指定的view进行动画,,动画类似UIAlertView的出现和消失
#import
<Foundation/Foundation.h>
 
@protocol CustomizedAlertAnimationDelegate;
 
 
@interface CustomizedAlertAnimation
:
NSObject
 

抱歉!评论已关闭.