iOS开发中touchesEnded点击结束函数

来源:互联网 发布:vidconvert mac 破解 编辑:程序博客网 时间:2024/06/05 00:16
/* 点击完成 点击Controller完成 */
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    // touches是一个数组/集合 集合不能重复 数组可以重复
    // 因为iOS支持多点触摸 最多11个点

    // 手指触摸在view [touches anyObject]取一个手指


    UITouch *oneTouch = [touches anyObject];


    if (oneTouch.view == headImageView) {
        // 是否点击到头像上了
        UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"选择头像照片" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"从相册取头像" otherButtonTitles:@"从摄像头拍头像", nil];
        // 把actionSheet显示在self.view上
        [as showInView:self.view];
    }
    
    // 点击了屏幕 所有输入框都失去焦点
    [nicknameField resignFirstResponder];

}



//sheet控件是从屏幕底部往上推出的控件,设置标题,同时可在代理方法中,执行相应的函数

UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"选择头像照片" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"从相册取头像" otherButtonTitles:@"从摄像头拍头像", nil];
        // 把actionSheet显示在self.view上

//sheet代理方法

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 

0 0
原创粉丝点击