Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
UIView - iPhone Development Wiki

UIView

From iPhone Development Wiki
Revision as of 09:59, 5 November 2009 by KennyTM~ (talk | contribs)

UIView is the root class of all UI elements.

Getting View Hierarchy Info

There are 2 ways of getting the view hierarchy info, the "human readable" -[UIView recursiveDescription] and "machine readable" -[UIView scriptingInfoWithChildren].

-recursiveDescription

Signature -(NSString*)recursiveDescription;
Available in 3.0 – 3.1

Returns the description of the view and its subviews.

Example output:

<UIWebView: 0x4116bb0; frame = (0 100; 320 230); layer = <CALayer: 0x4116c20>>
   <UIScroller: 0x411e110; frame = (0 0; 320 230); clipsToBounds = YES; autoresize = H; layer = <CALayer: 0x411e4d0>>
       <UIImageView: 0x411f460; frame = (0 0; 54 54); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x411f490>>
       <UIWebDocumentView: 0x4812c00; frame = (0 0; 320 230); layer = <UIWebLayer: 0x41171c0>>

-scriptingInfoWithChildren

Signature -(NSDictionary*)scriptingInfoWithChildren;
Available in 2.0 – 3.1

This function returns an NSDictionary with contains some information e.g. geometry, class name, etc.

Animation Blocks

Animation blocks are implemented by the UIViewAnimationState class with the following correspondences:

UIView methods Equivalent call
[UIView beginAnimations:identifier context:context]; [UIViewAnimationState pushViewAnimationState:identifier context:context];
[UIView commitAnimations]; [UIViewAnimationState popAnimationState];
[UIView setAnimationStartDate:date]; __currentViewAnimationState->_start = [date timeIntervalSinceReferenceDate];
[UIView setAnimationsEnabled:enabled]; __animate = enabled;
[UIView setAnimationDelegate:delegate]; if (__currentViewAnimationState->_delegate != delegate) {
  [__currentViewAnimationState->_delegate release];
  __currentViewAnimationState->_delegate = [
delegate retain];
}
[UIView setAnimationWillStartSelector:selector]; __currentViewAnimationState->_willStartSelector = selector;
[UIView setAnimationDidStopSelector:selector]; __currentViewAnimationState->_didEndSelector = selector;
[UIView setAnimationDuration:duration]; __currentViewAnimationState->_duration = duration;
[UIView setAnimationDelay:delay]; __currentViewAnimationState->_delay = delay;
[UIView setAnimationCurve:curve]; __currentViewAnimationState->_curve = curve;
[UIView setAnimationRepeatCount:repeatCount]; __currentViewAnimationState->_repeatCount = repeatCount;
[UIView setAnimationRepeatAutoreverses:autoreverses]; __currentViewAnimationState->_autoreverses = autoreverses;
[UIView setAnimationBeginsFromCurrentState:value]; __currentViewAnimationState->_useCurrentLayerState = value;
[UIView setAnimationTransition:transVal forView:container cache:cache]; __currentViewAnimationState->_transition = transVal;
__currentViewAnimationState->_transitionView = [
container retain];
__currentViewAnimationState->_cacheTransition =
cache;
[UIView areAnimationsEnabled]; __animate;

In above, __currentViewAnimationState is a global variable, which is a UIViewAnimationState. This value is automatically updated after calling +pushViewAnimationState:context: and +popAnimationState. NULL checks were omitted in the above codes for simplicity.

There are also a few undocumented methods:

UIView method Equivalent call
[UIView beginAnimations:identifier]; [UIView beginAnimations:identifier context:NULL];
[UIView _pendingAnimations]; __currentViewAnimationState != nil;
[UIView setAnimationPosition:position]; __currentViewAnimationState->_position = position;
[UIView disableAnimation]; __animate = NO;
[UIView enableAnimation]; __animate = YES;
[UIView setAnimationFrameInterval:interval]; __currentViewAnimationState->_frameInterval = interval;
[UIView setAnimationStartTime:time]; __currentViewAnimationState->_start = time;
[UIView setAnimationRoundsToInteger:rounds]; __currentViewAnimationState->_roundsToInteger = rounds;

There are also a few equivalent (probably deprecated) selectors:

  • +endAnimations = +commitAnimations
  • +setAnimationAutoreverses: = +setAnimationRepeatAutoreverses:
  • +setAnimationFromCurrentState: = +setAnimationBeginsFromCurrentState:

References