標籤:io ar cti log sp on ad c ef
1.設定搖動,或要使他變要第一響應者
[[UIApplication sharedApplication]setApplicationSupportsShakeToEdit:YES];
[self canBecomeFirstResponder];
2.實現下面幾個函數來控制搖一搖的觸發的動作
- (BOOL)canBecomeFirstResponder
{
return YES;// default is NO
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"開始搖動手機");
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"stop");
UIAlertView *yaoyiyao = [[UIAlertView alloc]initWithTitle:@"溫馨提示:" message:@"麻辣疙疤籽" delegate:self cancelButtonTitle:@"cancel"otherButtonTitles:@"back",nil ];
[yaoyiyao show];
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"取消");
}
3.提示框
UIAlertView *yaoyiyao = [[UIAlertView alloc]initWithTitle:@"溫馨提示:" message:@"您有新訊息" delegate:self cancelButtonTitle:@"cancel"otherButtonTitles:@"back",nil ];
@protocol UIAlertViewDelegate <NSObject> 這裡的協議可實現提示框裡的按鈕的功能
4.手勢的添加
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(back:)]; //設定手勢
[self.view addGestureRecognizer:tap];//將手勢添加到視圖上
5.webview上設定返回按鈕的做法
if (webView.canGoBack==YES) {
[webView goBack];
}
else
[self.navigationController popViewControllerAnimated:YES];
搖一搖和手勢