UIActionSheet不响应触摸 [英] UIActionSheet not responding to touches

查看:52
本文介绍了UIActionSheet不响应触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样设置的UIActionSheet:

I have a UIActionSheet that I set up like this:

-(void)trash:(id)sender
{
UIActionSheet *sheet = [[[UIActionSheet alloc] initWithTitle:@"Delete" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Remove text" otherButtonTitles:@"Remove tags", nil] autorelease];

[sheet showInView:self.view];

}

工作表按预期从屏幕底部显示,并且都正确.但是,没有一个按钮处于活动状态.唯一的出路是触摸主页"按钮.

The sheet appears from the bottom of the screen, as intended, and all correct. However none of the buttons are active. The only way out is to touch the Home button.

有什么我想念的吗?

视图self.view是视图控制器的视图.唯一奇怪的是它小于全屏高度,因为它位于键盘上方.

The view self.view is the view of the view controller. The only odd thing about it is that it is less than the full screen height because it sits above the keyboard.

// Never called
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;
{
    NSLog(@"%d",buttonIndex);
}

// Never called
- (void)actionSheet:(UIActionSheet *)actionSheet     didDismissWithButtonIndex:(NSInteger)buttonInde
{

}

// Never called
- (void)actionSheet:(UIActionSheet *)actionSheet     willDismissWithButtonIndex:(NSInteger)buttonIndex
{

}

// Called if I hit Home button
- (void)actionSheetCancel:(UIActionSheet *)actionSheet
{

}


// Called second
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet
{

}

// Called first
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{

}

推荐答案

如果视图上有键盘,则可以看到该键盘的textfield/textview是第一响应者.为了使任何控件都能响应触摸,它必须是第一响应者.

If there is a keyboard on the view, chances are the textfield/textview for which the keyboard is visible is the first responder. For any control to respond to touches, it has to be the first responder.

请确保您的操作表在显示时是第一响应者.

Make sure that your action sheet is the first responder when you display it.

这篇关于UIActionSheet不响应触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆