Class: UIAlertView
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)
-
- alertViewStyle
The kind of alert displayed to the user.
-
- cancelButtonIndex
The index number of the cancel button.
-
- delegate
The receiver’s delegate or nil if it doesn’t have a delegate.
-
- firstOtherButtonIndex
readonly
The index of the first other button.
-
- message
Descriptive text that provides more details than the title.
-
- numberOfButtons
readonly
The number of buttons on the alert view.
-
- title
The string that appears in the receiver’s title bar.
-
- visible
readonly
A Boolean value that indicates whether the receiver is displayed.
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)
-
- addButtonWithTitle:
Adds a button to the receiver with the given title.
-
- buttonTitleAtIndex:
Returns the title of the button at the given index.
-
- dismissWithClickedButtonIndex:animated:
Dismisses the receiver, optionally with animation.
-
- initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:
Convenience method for initializing an alert view.
-
- show
Displays the receiver using animation.
-
- textFieldAtIndex:
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.
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.
- (Integer) cancelButtonIndex
The index number of the cancel button. The button indices start at 0. If -1, then the index is not set.
- (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.
- (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.
- (String) message
Descriptive text that provides more details than the title.
- (Integer) numberOfButtons (readonly)
The number of buttons on the alert view. (read-only)
- (String) title
The string that appears in the receiver’s title bar.
- (Boolean) visible (readonly)
A Boolean value that indicates whether the receiver is displayed. (read-only) If YES, the receiver is displayed; otherwise, NO.
Instance Method Details
- (Integer) addButtonWithTitle(title)
Adds a button to the receiver with the given title.
- (String) buttonTitleAtIndex(buttonIndex)
Returns the title of the button at the given index.
- (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.
- (Object) initWithTitle(title, message:message, delegate:delegate, cancelButtonTitle:cancelButtonTitle, otherButtonTitles:otherButtonTitles, ...)
Convenience method for initializing an alert view.
- (Object) show
Displays the receiver using animation.
- (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.