IOS笔记 - UIActionSheet

	UIActionSheet *actionSheet = [[UIActionSheet alloc]
					// initWithTitle:是显示的标题,显示在操作表的顶部。
					initWithTitle:@"Are you sure?"
					// delegate:是操作表的委托,将在该表上的按钮被按下时收到通知,
					// 更确切地说,委托的ActionSheet:didDismissWithButtonIndex:
					// actionSheet:didDismisswithButtonIndex:方法将被调用。
					delegate:self
					// cancelButtonTitle:是取消按钮的标题,用户可以通过点击此按钮表明不希望继续操作。
					cancelButtonTitle:@"No way!"
					// destructiveButtonTitle:确定按钮的标题,同上相反。
					destructiveButtonTitle:@"Yes,I'm sure!"
					/ otherButtonTitle:是用于指定希望在表单上现实的其他按钮的数量,该参数可以使用各种值
					// otherButtonTitle:@"Foo",@"Bar",nil];
					otherButtonTitles:nil];
	[actionSheet showInView:self.view];
	[actionSheet release];


关于delegate,

-(void) actionSheet:(UIActionSheet *) actionSheet 
didDismissWithButtonIndex:(NSInteger) buttonIndex
{
	NSLog(@"buttonIndex is %d",buttonIndex);
	if (buttonIndex != [actionSheet cancelButtonIndex]) {
		NSString *msg = nil ;
		if (nameField.text.length) {
			msg = [[NSString alloc]initWithFormat:
				   @"You can breathe easy, %@, everything went OK.",nameField.text];
		} else {
			msg = @"You can breathe easy,everything went OK.";
		}
		
		UIAlertView *alert = [[UIAlertView alloc]
							  initWithTitle:@"Something was done" 
							  message:msg 
							  delegate:self 
							  cancelButtonTitle:@"Phew!" 
							  otherButtonTitles:nil];
		[alert show];
		[alert release];
		[msg release];

	}
}

Instance Methods

actionSheet:clickedButtonAtIndex:

Sent to the delegate when the user clicks a button on an action sheet.

- (void)actionSheet:( UIActionSheet *) actionSheet clickedButtonAtIndex:( NSInteger) buttonIndex
Parameters
actionSheet

The action sheet containing the button.

buttonIndex

The position of the clicked button. The button indices start at 0.

Discussion

The receiver is automatically dismissed after this method is invoked.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheet:didDismissWithButtonIndex:

Sent to the delegate after an action sheet is dismissed from the screen.

- (void)actionSheet:( UIActionSheet *) actionSheet didDismissWithButtonIndex:( NSInteger) buttonIndex
Parameters
actionSheet

The action sheet that was dismissed.

buttonIndex

The index of the button that was clicked. The button indices start at 0. If this is the cancel button index, the action sheet is canceling. If -1, the cancel button index is not set.

Discussion

This method is invoked after the animation ends and the view is hidden.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheet:willDismissWithButtonIndex:

Sent to the delegate before an action sheet is dismissed.

- (void)actionSheet:( UIActionSheet *) actionSheet willDismissWithButtonIndex:( NSInteger) buttonIndex
Parameters
actionSheet

The action sheet that is about to be dismissed.

buttonIndex

The index of the button that was clicked. If this is the cancel button index, the action sheet is canceling. If -1, the cancel button index is not set.

Discussion

This method is invoked before the animation begins and the view is hidden.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheetCancel:

Sent to the delegate before an action sheet is canceled.

- (void)actionSheetCancel:( UIActionSheet *) actionSheet
Parameters
actionSheet

The action sheet that will be canceled.

Discussion

If the action sheet’s delegate does not implement this method, clicking the cancel button is simulated and the action sheet is dismissed. Implement this method if you need to perform some actions before an action sheet is canceled. An action sheet can be canceled at any time by the system—for example, when the user taps the Home button. TheactionSheet:willDismissWithButtonIndex: and actionSheet:didDismissWithButtonIndex: methods are invoked after this method.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

didPresentActionSheet:

Sent to the delegate after an action sheet is presented to the user.

- (void)didPresentActionSheet:( UIActionSheet *) actionSheet
Parameters
actionSheet

The action sheet that was displayed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

willPresentActionSheet:

Sent to the delegate before an action sheet is presented to the user.

- (void)willPresentActionSheet:( UIActionSheet *) actionSheet
Parameters
actionSheet

The action sheet that is about to be displayed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

Instance Methods

actionSheet:clickedButtonAtIndex:

Sent to the delegate when the user clicks a button on an action sheet.

- (void)actionSheet:( UIActionSheet *) actionSheet clickedButtonAtIndex:( NSInteger) buttonIndex
Parameters
actionSheet

The action sheet containing the button.

buttonIndex

The position of the clicked button. The button indices start at 0.

Discussion

The receiver is automatically dismissed after this method is invoked.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheet:didDismissWithButtonIndex:

Sent to the delegate after an action sheet is dismissed from the screen.

- (void)actionSheet:( UIActionSheet *) actionSheet didDismissWithButtonIndex:( NSInteger) buttonIndex
Parameters
actionSheet

The action sheet that was dismissed.

buttonIndex

The index of the button that was clicked. The button indices start at 0. If this is the cancel button index, the action sheet is canceling. If -1, the cancel button index is not set.

Discussion

This method is invoked after the animation ends and the view is hidden.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheet:willDismissWithButtonIndex:

Sent to the delegate before an action sheet is dismissed.

- (void)actionSheet:( UIActionSheet *) actionSheet willDismissWithButtonIndex:( NSInteger) buttonIndex
Parameters
actionSheet

The action sheet that is about to be dismissed.

buttonIndex

The index of the button that was clicked. If this is the cancel button index, the action sheet is canceling. If -1, the cancel button index is not set.

Discussion

This method is invoked before the animation begins and the view is hidden.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheetCancel:

Sent to the delegate before an action sheet is canceled.

- (void)actionSheetCancel:( UIActionSheet *) actionSheet
Parameters
actionSheet

The action sheet that will be canceled.

Discussion

If the action sheet’s delegate does not implement this method, clicking the cancel button is simulated and the action sheet is dismissed. Implement this method if you need to perform some actions before an action sheet is canceled. An action sheet can be canceled at any time by the system—for example, when the user taps the Home button. TheactionSheet:willDismissWithButtonIndex: and actionSheet:didDismissWithButtonIndex: methods are invoked after this method.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

didPresentActionSheet:

Sent to the delegate after an action sheet is presented to the user.

- (void)didPresentActionSheet:( UIActionSheet *) actionSheet
Parameters
actionSheet

The action sheet that was displayed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

willPresentActionSheet:

Sent to the delegate before an action sheet is presented to the user.

- (void)willPresentActionSheet:( UIActionSheet *) actionSheet
Parameters
actionSheet

The action sheet that is about to be displayed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值