2011-10-27 49 views
2

的UIActivityIndi​​catorView假設有一個UIView作爲一個容器,它包含一個UIActivityIndicatorView等subviews.When的UIActivityIndicatorView是動畫,它的userInteractionEnabled屬性設置爲NO,這使得它所有的兄弟姐妹的意見停止接收輸入事件。瞭解iOS

我檢查了蘋果的文檔,它建議我們可以使用UIViewAnimationOptionAllowUserInteraction常量來解決這個問題。但我不知道在哪裏或哪個屬性設置這個常量。有沒有人遇到過這個問題並解決它?

回答

2

UIViewAnimationOptionAllowUserInteraction是用塊動畫視圖的選項之一。允許用戶在動畫時與視圖交互。

enum { 
    UIViewAnimationOptionLayoutSubviews   = 1 << 0, 
    UIViewAnimationOptionAllowUserInteraction  = 1 << 1, 
    UIViewAnimationOptionBeginFromCurrentState  = 1 << 2, 
    UIViewAnimationOptionRepeat     = 1 << 3, 
    UIViewAnimationOptionAutoreverse    = 1 << 4, 
    UIViewAnimationOptionOverrideInheritedDuration = 1 << 5, 
    UIViewAnimationOptionOverrideInheritedCurve = 1 << 6, 
    UIViewAnimationOptionAllowAnimatedContent  = 1 << 7, 
    UIViewAnimationOptionShowHideTransitionViews = 1 << 8, 

    UIViewAnimationOptionCurveEaseInOut   = 0 << 16, 
    UIViewAnimationOptionCurveEaseIn    = 1 << 16, 
    UIViewAnimationOptionCurveEaseOut    = 2 << 16, 
    UIViewAnimationOptionCurveLinear    = 3 << 16, 

    UIViewAnimationOptionTransitionNone   = 0 << 20, 
    UIViewAnimationOptionTransitionFlipFromLeft = 1 << 20, 
    UIViewAnimationOptionTransitionFlipFromRight = 2 << 20, 
    UIViewAnimationOptionTransitionCurlUp   = 3 << 20, 
    UIViewAnimationOptionTransitionCurlDown  = 4 << 20, 
    UIViewAnimationOptionTransitionCrossDissolve = 5 << 20, 
    UIViewAnimationOptionTransitionFlipFromTop  = 6 << 20, 
    UIViewAnimationOptionTransitionFlipFromBottom = 7 << 20, 
}; 
typedef NSUInteger UIViewAnimationOptions; 

但我不知道它是如何幫助您使用UIActivityIndi​​catorView。簡單的例子:

[UIView animateWithDuration:0.4f 
         delay:0.2f 
        options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut 
       animations:^{ 
        [myView setFrame:CGRectOffset(view.frame, 0, -100)]; 
       } 
       completion:^(BOOL finished){ 
         NSLog(@"completed"); 
        } 
]; 
+0

當使用'UIActivityIndi​​catorView'時,我通常會創建空的持有者視圖,將它放在前面並放入它UIActivityIndi​​catorView。當進程完成時,只需刪除此視圖 – beryllium

+0

謝謝,這有助於很多 –