Class: UIPickerView

Inherits:
UIView show all

Overview

The UIPickerView class implements objects, called picker views, that use a spinning-wheel or slot-machine metaphor to show one or more sets of values. Users select values by rotating the wheels so that the desired row of values aligns with a selection indicator.

Instance Attribute Summary (collapse)

Attributes inherited from UIView

#alpha, #autoresizesSubviews, #autoresizingMask, #backgroundColor, #bounds, #center, #clearsContextBeforeDrawing, #clipsToBounds, #contentMode, #contentScaleFactor, #exclusiveTouch, #frame, #gestureRecognizers, #hidden, #layer, #multipleTouchEnabled, #opaque, #restorationIdentifier, #subviews, #superview, #tag, #transform, #userInteractionEnabled, #window

Attributes inherited from UIResponder

#inputAccessoryView, #inputView, #undoManager

Instance Method Summary (collapse)

Methods inherited from UIView

#addConstraint:, #addConstraints:, #addGestureRecognizer:, #addSubview:, #alignmentRectForFrame:, #alignmentRectInsets, animateWithDuration:animations:, animateWithDuration:animations:completion:, animateWithDuration:delay:options:animations:completion:, areAnimationsEnabled, beginAnimations:context:, #bringSubviewToFront:, commitAnimations, #constraints, #constraintsAffectingLayoutForAxis:, #contentCompressionResistancePriorityForAxis:, #contentHuggingPriorityForAxis:, #convertPoint:fromView:, #convertPoint:toView:, #convertRect:fromView:, #convertRect:toView:, #decodeRestorableStateWithCoder:, #didAddSubview:, #didMoveToSuperview, #didMoveToWindow, #drawRect:, #drawRect:forViewPrintFormatter:, #encodeRestorableStateWithCoder:, #endEditing:, #exchangeSubviewAtIndex:withSubviewAtIndex:, #exerciseAmbiguityInLayout, #frameForAlignmentRect:, #gestureRecognizerShouldBegin:, #hasAmbiguousLayout, #hitTest:withEvent:, #initWithFrame:, #insertSubview:aboveSubview:, #insertSubview:atIndex:, #insertSubview:belowSubview:, #intrinsicContentSize, #invalidateIntrinsicContentSize, #isDescendantOfView:, layerClass, #layoutIfNeeded, #layoutSubviews, #needsUpdateConstraints, #pointInside:withEvent:, #removeConstraint:, #removeConstraints:, #removeFromSuperview, #removeGestureRecognizer:, requiresConstraintBasedLayout, #sendSubviewToBack:, setAnimationBeginsFromCurrentState:, setAnimationCurve:, setAnimationDelay:, setAnimationDelegate:, setAnimationDidStopSelector:, setAnimationDuration:, setAnimationRepeatAutoreverses:, setAnimationRepeatCount:, setAnimationStartDate:, setAnimationTransition:forView:cache:, setAnimationWillStartSelector:, setAnimationsEnabled:, #setContentCompressionResistancePriority:forAxis:, #setContentHuggingPriority:forAxis:, #setNeedsDisplay, #setNeedsDisplayInRect:, #setNeedsLayout, #setNeedsUpdateConstraints, #setTranslatesAutoresizingMaskIntoConstraints:, #sizeThatFits:, #sizeToFit, #systemLayoutSizeFittingSize:, transitionFromView:toView:duration:options:completion:, transitionWithView:duration:options:animations:completion:, #translatesAutoresizingMaskIntoConstraints, #updateConstraints, #updateConstraintsIfNeeded, #viewForBaselineLayout, #viewPrintFormatter, #viewWithTag:, #willMoveToSuperview:, #willMoveToWindow:, #willRemoveSubview:

Methods inherited from UIResponder

#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Object) dataSource

The data source for the picker view. The data source must adopt the UIPickerViewDataSource protocol and implement the required methods to return the number of components and the number of rows in each component.

Returns:

- (Object) delegate

The delegate for the picker view. The delegate must adopt the UIPickerViewDelegate protocol and implement the required methods to return the drawing rectangle for rows in each component. It also provides the content for each component’s row, either as a string or a view, and it typically responds to new selections or deselections.

Returns:

- (Integer) numberOfComponents (readonly)

Gets the number of components for the picker view. (read-only) A UIPickerView object fetches the value of this property from the data source and and caches it. The default value is zero.

Returns:

- (Boolean) showsSelectionIndicator

A Boolean value that determines whether the selection indicator is displayed. If the value of the property is YES, the picker view shows a clear overlay across the current row. The default value of this property is NO.

Returns:

  • (Boolean)

Instance Method Details

- (Integer) numberOfRowsInComponent(component)

Returns the number of rows for a component. A picker view fetches the value of this property from the data source and and caches it. The default value is zero.

Parameters:

  • component (Integer)

    A zero-indexed number identifying a component.

Returns:

  • (Integer)

    The number of rows in the given component.

- (Object) reloadAllComponents

Reloads all components of the picker view. Calling this method causes the picker view to query the delegate for new data for all components.

Returns:

- (Object) reloadComponent(component)

Reloads a particular component of the picker view. Calling this method causes the picker view to query the delegate for new data for the given component.

Parameters:

  • component (Integer)

    A zero-indexed number identifying a component of the picker view.

Returns:

- (CGSize) rowSizeForComponent(component)

Returns the size of a row for a component. A picker view fetches the value of this property by calling the pickerView:widthForComponent: and pickerView:rowHeightForComponent: delegate methods, and caches it. The default value is (0, 0).

Parameters:

  • component (Integer)

    A zero-indexed number identifying a component.

Returns:

  • (CGSize)

    The size of rows in the given component. This is generally the size required to display the largest string or view used as a row in the component.

- (Integer) selectedRowInComponent(component)

Returns the index of the selected row in a given component.

Parameters:

  • component (Integer)

    A zero-indexed number identifying a component of the picker view.

Returns:

  • (Integer)

    A zero-indexed number identifying the selected row, or -1 if no row is selected.

- (Object) selectRow(row, inComponent:component, animated:animated)

Selects a row in a specified component of the picker view.

Parameters:

  • row (Integer)

    A zero-indexed number identifying a row of component.

  • component (Integer)

    A zero-indexed number identifying a component of the picker view.

  • animated (Boolean)

    YES to animate the selection by spinning the wheel (component) to the new value; if you specify NO, the new selection is shown immediately.

Returns:

- (UIView) viewForRow(row, forComponent:component)

Returns the view used by the picker view for a given row and component.

Parameters:

  • row (Integer)

    The zero-indexed number of a row of the picker view.

  • component (Integer)

    The zero-indexed number of a component of the picker view.

Returns:

  • (UIView)

    The view provided by the delegate in the pickerView:viewForRow:forComponent:reusingView: method. Returns nil if the specified row of the component is not visible or if the delegate does not implement pickerView:viewForRow:forComponent:reusingView:.