首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIActionSheet不响应触摸

UIActionSheet不响应触摸
EN

Stack Overflow用户
提问于 2009-05-18 04:00:29
回答 3查看 2.5K关注 0票数 4

我有一个这样设置的UIActionSheet:

代码语言:javascript
复制
-(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];

}

工作表将按预期从屏幕底部显示,并且都正确无误。但是,这些按钮都不是活动的。唯一的出路就是触摸Home键。

我是不是漏掉了什么?

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

代码语言:javascript
复制
// 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
{

}
EN

回答 3

Stack Overflow用户

发布于 2009-05-18 09:45:15

如果视图上有键盘,则键盘可见的textfield/textview很可能是第一响应者。对于任何要响应触摸的控件,它都必须是第一个响应者。

当您展示行动单时,请确保它是第一个响应者。

票数 1
EN

Stack Overflow用户

发布于 2009-05-18 08:06:47

仔细检查firstResponder状态。

票数 0
EN

Stack Overflow用户

发布于 2009-09-17 06:06:30

您不需要在self.vew中显示视图,而需要在Appdelegate的根视图中显示。

使用appDelegate.window.subviews对象属性索引:0;

我在AppDelegate中有这个方法:

代码语言:javascript
复制
-(UIView *) getRootView {
return [self.window.subviews objectAtIndex:0];

}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/876209

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档