博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
长按事件--UILongPressGestureRecognizer
阅读量:5250 次
发布时间:2019-06-14

本文共 2452 字,大约阅读时间需要 8 分钟。

//

//  touchViewController.m
//  touch
//
//  Created by joe visen on 11-9-21.
//  Copyright 2011 mjrj.com. All rights reserved.
//
#import "touchViewController.h"
@implementation touchViewController
- (void)loadView{
    [super loadView];
    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showResetMenu:)];
    [self.view addGestureRecognizer:longPressGesture];
    [longPressGesture release];
   
   
    //[view release];
}
- (void)showResetMenu:(UILongPressGestureRecognizer *)gestureRecognizer
{
    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
        UIMenuController *menuController = [UIMenuController sharedMenuController];
        UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:@"Reset" action:@selector(resetPiece:)];
        CGPoint location = [gestureRecognizer locationInView:[gestureRecognizer view]];
       
        [self becomeFirstResponder];
        [menuController setMenuItems:[NSArray arrayWithObject:resetMenuItem]];
        [menuController setTargetRect:CGRectMake(location.x, location.y, 0, 0) inView:[gestureRecognizer view]];
        [menuController setMenuVisible:YES animated:YES];
       
        //pieceForReset = [gestureRecognizer view];
       
        [resetMenuItem release];
    }
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
    // Release any retained subviews of the main view.
   
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
    [super dealloc];
}
@end

转载于:https://www.cnblogs.com/zhwl/archive/2013/01/15/2861512.html

你可能感兴趣的文章
人人生而平等,享有生命自由和追求幸福生活的权利
查看>>
【基础】寻找2的幂
查看>>
传送门
查看>>
Maven安装
查看>>
2017 Multi-University Training Contest - Team 7 hdu6127 hdu6130
查看>>
从零开始利用vue-cli搭建简单音乐网站(五)
查看>>
好人坏人
查看>>
ASP出500错误怎么办(理论上并不止500错误,其他错误可以同样可以获得更多信息以帮助解决问题)...
查看>>
[MGR——Mysql的组复制之多主模式 ] 详细搭建部署过程
查看>>
数组Demo
查看>>
python程序在命令行执行提示ModuleNotFoundError: No module named 'XXX' 解决方法
查看>>
Go Revel - Results(响应)
查看>>
使用localStorage实现历史记录搜索功能
查看>>
linux搭建django运行环境
查看>>
原版SQLHelper.cs下载
查看>>
js库中$冲突的解决方法
查看>>
Java Script--------问题错误解决意外的终止输入Uncaught SyntaxError: Unexpected end of input解决办法...
查看>>
MongoDB
查看>>
五十二、使用Adb命令卸载android应用配置方法
查看>>
WebSerivce与WebAPI的区别
查看>>