1.UIAlterview 是苹果自带的对话框的,今天学习了使用方法就和大家分享一下它的使用方法:
2.定义一个alterview的对象
UIAlertView *alterView = [[UIAlertView alloc]initWithTitle:@"请选择操作" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"编辑该情景组",@"删除该情景组", nil];
[alterView show];
3.实现UIAlterviewDelegate的代理方法:
#pragma mark - UIAlterviewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"编辑该情景"]){
[self editCustomScene];
}
else if ([title isEqualToString:@"删除该情景"]){
[self deleteCustomScene];
}
或者为另外的一个代理方法:
#pragma mark - UIAlterviewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
switich (buttonIndex) {
case :1 {
[self editCustomScene];
}
case :2{
[self deleteCustomScene];
}
}