Class: UIAlertView

Inherits:
UIView show all

Overview

Use the UIAlertView class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of UIActionSheet).

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

- (UIAlertViewStyle) alertViewStyle

The kind of alert displayed to the user.

Returns:

- (Integer) cancelButtonIndex

The index number of the cancel button. The button indices start at 0. If -1, then the index is not set.

Returns:

- (Object) delegate

The receiver’s delegate or nil if it doesn’t have a delegate. See UIAlertViewDelegate Protocol Reference for the methods this delegate should implement.

Returns:

- (Integer) firstOtherButtonIndex (readonly)

The index of the first other button. (read-only) The button indices start at 0. If -1, then the index is not set. This property is ignored if there are no other buttons. The default value is -1.

Returns:

- (String) message

Descriptive text that provides more details than the title.

Returns:

- (Integer) numberOfButtons (readonly)

The number of buttons on the alert view. (read-only)

Returns:

- (String) title

The string that appears in the receiver’s title bar.

Returns:

- (Boolean) visible (readonly)

A Boolean value that indicates whether the receiver is displayed. (read-only) If YES, the receiver is displayed; otherwise, NO.

Returns:

  • (Boolean)

Instance Method Details

- (Integer) addButtonWithTitle(title)

Adds a button to the receiver with the given title.

Parameters:

  • title (String)

    The title of the new button.

Returns:

  • (Integer)

    The index of the new button. Button indices start at 0 and increase in the order they are added.

- (String) buttonTitleAtIndex(buttonIndex)

Returns the title of the button at the given index.

Parameters:

  • buttonIndex (Integer)

    The index of the button. The button indices start at 0.

Returns:

  • (String)

    The title of the button specified by index buttonIndex.

- (Object) dismissWithClickedButtonIndex(buttonIndex, animated:animated)

Dismisses the receiver, optionally with animation. In iOS 4.0, you may want to call this method whenever your application moves to the background. An alert view is not dismissed automatically when an application moves to the background. This behavior differs from previous versions of the operating system, where they were canceled automatically when the application was terminated. Dismissing the alert view gives your application a chance to save changes or abort the operation and perform any necessary cleanup in case your application is terminated later.

Parameters:

  • buttonIndex (Integer)

    The index of the button that was clicked just before invoking this method. The button indices start at 0.

  • animated (Boolean)

    YES if the receiver should be removed by animating it first; otherwise, NO if it should be removed immediately with no animation.

Returns:

- (Object) initWithTitle(title, message:message, delegate:delegate, cancelButtonTitle:cancelButtonTitle, otherButtonTitles:otherButtonTitles, ...)

Convenience method for initializing an alert view.

Parameters:

  • title

    The string that appears in the receiver’s title bar.

  • message

    Descriptive text that provides more details than the title.

  • delegate

    The receiver’s delegate or nil if it doesn’t have a delegate.

  • cancelButtonTitle

    The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title.

  • otherButtonTitles,

    The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons.

  • ...

    Titles of additional buttons to add to the receiver, terminated with nil.

Returns:

  • (Object)

    Newly initialized alert view.

- (Object) show

Displays the receiver using animation.

Returns:

- (UITextField) textFieldAtIndex(textFieldIndex)

Returns the text field at the given index The number of text fields present in an alert is dependent on the style of the alert.Alert StyleText FieldsUIAlertViewStyleDefaultNo user-editable text fields.UIAlertViewStyleSecureTextInputA single text field at index 0.UIAlertViewStylePlainTextInputA single text field at index 0.UIAlertViewStyleLoginAndPasswordInputThe login field is at index 0. The password field is at index 1.If your application attempts to retrieve a text field with an index that it out of bounds, the alert raises an NSRangeException.

Parameters:

  • textFieldIndex (Integer)

    The index of the text field. The text field indices start at 0.

Returns:

  • (UITextField)

    The text field specified by index textFieldIndex.