iOS UIAlertView 和 UIActionSheet 的使用
UIAlertView 类似于Windows上 的MessageBox.一点小记录,哎!现在是博客控了,什么都想记下,虽然简单并且苹果的相关技术文档也有说明,还是写下来。强迫症的初期表现出来啦。。。。
贴代码:
一般的使用
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"hello" message:@"I'm Apple" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil]; [alert show]; [alert release];
有多个按钮的时候
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"hello" message:@"O哈啊" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel",@"Ignore",nil ];
UIAlertViewDelegate 中的
- (void) alertView:(UIAlertView *)alertview
clickedButtonAtIndex:(NSInteger)buttonIndex
方法可以知道你点的是那个按钮。
UIActionSheet是从屏幕底部弹起的一个模态对话框,它的使用也很简单
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?" delegate:self cancelButtonTitle:@"No Way!" destructiveButtonTitle:@"Yes, I'm sure!" otherButtonTitles:nil]; [actionSheet showInView:self.view];
浙公网安备 33010602011771号