ios6.0中,UIAlertView不能在子线程中执行了
2013-04-17 18:54
225 查看
+(DisplayErrorMsg *)sharedDisplayErrorMsg
{
static DisplayErrorMsg *instance = nil;
@synchronized(instance)
{
if (instance == nil) {
instance = [[DisplayErrorMsg alloc] init];
}
}
return instance;
}
-(void)showAlertView:(NSString *)title Message:(NSString *)msg
{
NSArray *array = [NSArray arrayWithObjects:title,msg, nil];
[self performSelectorOnMainThread:@selector(doAlert:) withObject:array waitUntilDone:NO];
}
-(void)doAlert:(NSArray *)array
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[array objectAtIndex:0] message:[array objectAtIndex:1] delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.window addSubview:alert];
[alert show];
[alert release];
}
{
static DisplayErrorMsg *instance = nil;
@synchronized(instance)
{
if (instance == nil) {
instance = [[DisplayErrorMsg alloc] init];
}
}
return instance;
}
-(void)showAlertView:(NSString *)title Message:(NSString *)msg
{
NSArray *array = [NSArray arrayWithObjects:title,msg, nil];
[self performSelectorOnMainThread:@selector(doAlert:) withObject:array waitUntilDone:NO];
}
-(void)doAlert:(NSArray *)array
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[array objectAtIndex:0] message:[array objectAtIndex:1] delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.window addSubview:alert];
[alert show];
[alert release];
}
相关文章推荐
- 在非主线程中不能操作主线程中的View
- 调用线程对象的start()方法会执行run(),为什么不能直接调用run()方法??
- ios7 UIAlertView 不能加自己View
- Daemon守护线程让finally里面的语句不能执行
- 一个小白的起点 android 主线程不能下载图片到imageview
- 关于Webview执行goBack不能返回的问题解决
- 自定义的UIAlertView不能在iOS7上正常显示
- UIAlertView message 居左对齐 显示ios7以后不能用的启发
- Android WebView不能执行Ajax的解决办法
- 自定义View解决多个跑马灯不能同时执行的问题
- 自定义的UIAlertView不能在iOS7上正常显示
- 非UI线程不能更新View源码探索
- android中network的连接不能在直接在主线程中执行
- 求开4个线程4秒内执行完以下程序;部分代码已标注不能修改(多线程)
- 主线程不能执行耗时的操作,子线程不能更新Ui
- 主线程负责交互(事件处理)和UI绘制(onDraw), 只能在主线程访问View, 其他线程不能直接访问View (Android)
- 在Application的onCreate中创建线程,线程不能被执行
- android.view.ViewRootImpl$CalledFromWrongThreadException:Android2.3后耗时线程不可以在UI线程中执行
- alertView不能自动隐藏——谈多线程执行延迟对应用程序的影响
- IOS 7 自定义的UIAlertView不能在iOS7上正常显示