提醒窗口,单按钮,多按钮,播放声音,播放声音振动
来源:互联网 发布:淘宝千人千面害死卖家 编辑:程序博客网 时间:2024/05/17 01:22
//
// ViewController.m
// GettingAttention
//
// Created by John Ray on 7/27/13.
// Copyright (c) 2013 John E. Ray. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic)IBOutlet UILabel *userOutput;
- (IBAction)doAlert:(id)sender;
- (IBAction)doMultiButtonAlert:(id)sender;
- (IBAction)doAlertInput:(id)sender;
- (IBAction)doActionSheet:(id)sender;
- (IBAction)doSound:(id)sender;
- (IBAction)doAlertSound:(id)sender;
- (IBAction)doVibration:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)doAlert:(id)sender {
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:@"Alert Button Selected"
message:@"I need your attention NOW!"
delegate: nil
cancelButtonTitle: @"Ok"
otherButtonTitles: nil];
[alertDialog show];
}
- (IBAction)doMultiButtonAlert:(id)sender {
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:@"Alert Button Selected"
message:@"I need your attention NOW!"
delegate: self
cancelButtonTitle: @"Ok"
otherButtonTitles: @"Maybe Later", @"Never", nil];
[alertDialog show];
}
- (IBAction)doAlertInput:(id)sender {
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle: @"Email Address"
message:@"Please enter your email address:"
delegate: self
cancelButtonTitle: @"Ok"
otherButtonTitles: nil];
alertDialog.alertViewStyle=UIAlertViewStylePlainTextInput;
[alertDialog show];
}
- (IBAction)doActionSheet:(id)sender {
UIActionSheet *actionSheet;
actionSheet=[[UIActionSheetalloc] initWithTitle:@"Available Actions"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Destroy"
otherButtonTitles:@"Negotiate",@"Compromise",nil];
actionSheet.actionSheetStyle=UIActionSheetStyleDefault;
[actionSheet showFromRect:[(UIButton *)senderframe]
inView:self.viewanimated:YES];
}
- (IBAction)doSound:(id)sender {
SystemSoundID soundID;
NSString *soundFile = [[NSBundlemainBundle]
pathForResource:@"soundeffect"ofType:@"wav"];
AudioServicesCreateSystemSoundID((__bridgeCFURLRef)
[NSURLfileURLWithPath:soundFile]
, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)doAlertSound:(id)sender {
SystemSoundID soundID;
NSString *soundFile = [[NSBundlemainBundle]
pathForResource:@"alertsound"ofType:@"wav"];
AudioServicesCreateSystemSoundID((__bridgeCFURLRef)
[NSURLfileURLWithPath:soundFile]
, &soundID);
AudioServicesPlayAlertSound(soundID);
}
- (IBAction)doVibration:(id)sender {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *buttonTitle=[actionSheetbuttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"Destroy"]) {
self.userOutput.text=@"Clicked 'Destroy'";
} else if ([buttonTitleisEqualToString:@"Negotiate"]) {
self.userOutput.text=@"Clicked 'Negotiate'";
} else if ([buttonTitleisEqualToString:@"Compromise"]) {
self.userOutput.text=@"Clicked 'Compromise'";
} else {
self.userOutput.text=@"Clicked 'Cancel'";
}
}
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *buttonTitle=[alertViewbuttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"Maybe Later"]) {
self.userOutput.text=@"Clicked 'Maybe Later'";
} else if ([buttonTitleisEqualToString:@"Never"]) {
self.userOutput.text=@"Clicked 'Never'";
} else {
self.userOutput.text=@"Clicked 'Ok'";
}
if ([alertView.title
isEqualToString:@"Email Address"]) {
self.userOutput.text=[[alertViewtextFieldAtIndex:0] text];
}
}
@end
- 提醒窗口,单按钮,多按钮,播放声音,播放声音振动
- 点击按钮播放声音
- 添加按钮声音 播放声音
- ios播放声音和振动
- iPhone开发播放音乐与按钮声音
- 点击按钮播放声音简单实现。
- iOS——播放声音和振动
- MFC点击按钮发出声音_playsound_循环/单次播放_声音文件加入程序中
- [转][iPhone开发笔记]-音频播放/为按钮添加声音
- Unity3D开发之3D按钮的声音播放
- 播放声音
- 播放声音
- 播放声音
- 播放声音
- 播放声音
- iOS8 播放系统声音、提醒声音…
- Notification进阶之页面跳转、振动、播放声音
- 多平台声音播放方案
- 图文解说:Nginx+tomcat配置集群负载均衡
- SQL 游标的使用
- 罐类容器管理的处置与隐患办法
- 故宫网售朝珠耳机 专家提醒注意保护知识产权(图)
- 【转】enable_irq_wake是如何起作用的
- 提醒窗口,单按钮,多按钮,播放声音,播放声音振动
- images can't contain alpha channels or transparencies
- 第九周上机实践项目4我的小九九
- Android .9.PNG图片制作
- Lucene 中.fdx 和 .fdt 和.tis和.tii 还有.cfs含义
- vs2005 编译遇到的问题收集
- R:获取帮助
- adr与ldr的区别1
- 二分插入排序