使用线程显示活动指示器视图在 gdb 中显示此错误?
我在 uitableviewcell 的 didselectrow 方法上使用它,
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];
它工作正常,但它在 gdb 中显示错误,如下所示
2009-08-10 12:45:01.313 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): Object 0x458200 of class UIView autoreleased with no泳池就位 - 只是漏水 堆栈:(0x907d7adf 0x906e41f2 0x29a6 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2) 2009-08-10 12:45:01.314 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): NSCFString 类的对象 0x2a0e8 自动释放,没有池 - 只是泄漏 堆栈:(0x907d7adf 0x906e41f2 0x30ad10b0 0x30ad12e6 0x29c5 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2)
我也尝试过计时器,但不起作用
我的计时器代码是这个
MyTimer = [NSTimer timerWithTimeInterval:0 .01 目标:self 选择器:@selector(showMyWaitView) userInfo:nil 重复:不]; [[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];
我也尝试过这个
MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[NSThread sleepForTimeInterval:0.03];
这是我的 showMyWaitView 方法
-(void)showMyWaitView
{
[self.view addSubview:MyWaitViewObj.view];
}
这是我的 did selectrow 方法
if(MyWaitViewObj==nil)
{
MyWaitViewObj = [[MyWaitViewController alloc] initWithNibName:@"MyWaitView" bundle:nil];
}
//MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
MyTimer = [NSTimer timerWithTimeInterval:0.01 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];
//[NSThread sleepForTimeInterval:0.03];
[indexTableView deselectRowAtIndexPath:indexPath animated:YES];
categoryId = [[listOfCategoryId objectAtIndex:indexPath.section] intValue];
categoryType=[[listOfCategoryType objectAtIndex:indexPath.section] intValue];
[self getFlashCard:categoryId];
flashcardid = [[flashCardsId objectAtIndex:indexPath.row] intValue];
//NSLog(@"%s %d %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);
if(MyPageViewControllerObj==nil)
{
MyPageViewController *vController= [[MyPageViewController alloc] initWithNibName:@"MyPageView" bundle:[NSBundle mainBundle]];
self.MyPageViewControllerObj=vController;
[vController release];
}
//
MyPageViewControllerObj.sessionid=sessionid;
MyPageViewControllerObj.categoryID = categoryId;
MyPageViewControllerObj.flashcardIdforcount = flashcardid;
MyPageViewControllerObj.categoryType=categoryType;
MyPageViewControllerObj.indexViewControllerobj=self;
[self.navigationController pushViewController:MyPageViewControllerObj animated:YES];
[MyPageViewControllerObj refreshMyPageView];
//[MyPageViewControllerObj release];
NSLog(@"My MySlidingController View Ka retain Count=%d",[MyPageViewControllerObj retainCount]);
[MyWaitViewObj.view removeFromSuperview];
我如何使用计时器显示活动指示器 请帮助我或告诉我这个 gdb 错误会导致应用程序崩溃
i m using this on uitableviewcell's didselectrow method
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];
it works fine but it shows error in gdb like this
2009-08-10 12:45:01.313 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): Object 0x458200 of class UIView autoreleased with no pool in place - just leaking
Stack: (0x907d7adf 0x906e41f2 0x29a6 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2)
2009-08-10 12:45:01.314 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): Object 0x2a0e8 of class NSCFString autoreleased with no pool in place - just leaking
Stack: (0x907d7adf 0x906e41f2 0x30ad10b0 0x30ad12e6 0x29c5 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2)
i have also tried timer but that didn't work
my Timer Code is This
MyTimer = [NSTimer timerWithTimeInterval:0.01 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];
i have also tried this
MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[NSThread sleepForTimeInterval:0.03];
and this is my showMyWaitView method
-(void)showMyWaitView
{
[self.view addSubview:MyWaitViewObj.view];
}
here is my did selectrow method
if(MyWaitViewObj==nil)
{
MyWaitViewObj = [[MyWaitViewController alloc] initWithNibName:@"MyWaitView" bundle:nil];
}
//MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
MyTimer = [NSTimer timerWithTimeInterval:0.01 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];
//[NSThread sleepForTimeInterval:0.03];
[indexTableView deselectRowAtIndexPath:indexPath animated:YES];
categoryId = [[listOfCategoryId objectAtIndex:indexPath.section] intValue];
categoryType=[[listOfCategoryType objectAtIndex:indexPath.section] intValue];
[self getFlashCard:categoryId];
flashcardid = [[flashCardsId objectAtIndex:indexPath.row] intValue];
//NSLog(@"%s %d %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);
if(MyPageViewControllerObj==nil)
{
MyPageViewController *vController= [[MyPageViewController alloc] initWithNibName:@"MyPageView" bundle:[NSBundle mainBundle]];
self.MyPageViewControllerObj=vController;
[vController release];
}
//
MyPageViewControllerObj.sessionid=sessionid;
MyPageViewControllerObj.categoryID = categoryId;
MyPageViewControllerObj.flashcardIdforcount = flashcardid;
MyPageViewControllerObj.categoryType=categoryType;
MyPageViewControllerObj.indexViewControllerobj=self;
[self.navigationController pushViewController:MyPageViewControllerObj animated:YES];
[MyPageViewControllerObj refreshMyPageView];
//[MyPageViewControllerObj release];
NSLog(@"My MySlidingController View Ka retain Count=%d",[MyPageViewControllerObj retainCount]);
[MyWaitViewObj.view removeFromSuperview];
how do i show activity indicator using timer please help me or tell me will this gdb error cause application crash
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你要设置一个线程,你需要设置运行循环并为该线程创建一个 NSAutoreleasePool,当线程退出时它会被释放。 问题是,当您像这样关闭选择器时,您什么都没有做。 您的 showMyWait 应该设置发布池,来自 NSThread 文档
If you're setting up a Thread, you need to set up the run loop and create an NSAutoreleasePool for that thread as well, which is released when the Thread exits. The problem is you're doing neither when you fire off your selector like that. Your showMyWait should set up the release pool, from NSThread documentation
所有 UI 更新必须在主线程上进行。
All UI updates must be made on the main thread.