zoukankan      html  css  js  c++  java
  • [iOS]学习笔记8 (iOS之阻塞)

    我感觉,这个可以Win32里面的while( PeekMessage( ... ) )是一会儿事情。比较简单。

    CFRunLoopRun();就完成了这个事情。

    那么如何解除这个Block呢?

    可以用这个:

    CFRunLoopStop( someLoop );

    someLoop可以通过CFRunLoopGetCurrent()函数来获得。

    这样就可以轻易地等待各种线程了,比如说动画线程。

    @interface UIViewDelegate : NSObject
    {
    	CFRunLoopRef     _currentLoop;
    }
    @end
    
    @implementation UIViewDelegate
    -(id) init:(CFRunLoopRef)runLoop 
    {
    	if (self = [super init]) 
                  _currentLoop = runLoop;
    	return self;
    }
    
    -(void) animationFinished: (id) sender
    {
    	CFRunLoopStop(_currentLoop);
    }
    @end
    
    @implementation UIView (Block)
    + (void) commitAnimationsAndBlock
    {
    	CFRunLoopRef currentLoop = CFRunLoopGetCurrent();
    	UIViewDelegate *delegate = [[UIViewDelegate alloc] init:currentLoop];
    	[UIView setAnimationDelegate:delegate];
    	[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
    	[UIView commitAnimations];
    	CFRunLoopRun();
    	[delegate release];
    }
    @end
    

      

  • 相关阅读:
    django media配置
    django model项目外操作
    django 快捷代码提示
    django静态文件路径配置
    selenium爬取网易云
    selenium
    pyquery
    beautifulsoup
    Kafka与.net core(三)kafka操作
    Oracle 日期类型timestamp(时间戳)和date类型使用
  • 原文地址:https://www.cnblogs.com/healerkx/p/2327521.html
Copyright © 2011-2022 走看看