iPhone操作表取消按钮仅响应触摸近中心

时间:2011-12-21 07:12:34

标签: ios uiactionsheet

之前我遇到过这样的事情,其中​​一个按钮只响应部分视图中的触摸。我发现一个透明区域的图像视图位于更高的z级别,这掩盖了重叠发生的触摸。这是因为在添加模糊视图之前将按钮添加为子视图。

在动作表的情况下,我认为它将处于最高的z级别而不是其他任何事情。由于操作表刚刚初始化并显示,因此我无法看到某些内容覆盖按钮。

(为了它的价值,我只是将应用程序转换为通用应用程序,并在iOS 4.3和5.0中进行测试。在iPad上的操作表中没有取消按钮。当模拟iPhone时出现此问题iOS 4.3和5.0都有。)

我正在寻找关于导致问题的原因的其他想法。

UPDATE 以下是显示操作表的代码

- (void) shareButtonPressed {

    SHKItem *item = [SHKItem larkspreeSearchResult:searchResult];
    item.image = eventImageRaw;

    // Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

    // Display the action sheet
    [actionSheet showInView:self.view];

}

由于这是针对子类化的操作表,因此,它也可能对ShareKit有帮助。

+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
{
SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")
                                                      delegate:self
                                         cancelButtonTitle:nil
                                    destructiveButtonTitle:nil
                                         otherButtonTitles:nil];
as.item = [[[SHKItem alloc] init] autorelease];
as.item.shareType = type;

as.sharers = [NSMutableArray arrayWithCapacity:0];
NSArray *favoriteSharers = [SHK favoriteSharersForType:type];

// Add buttons for each favorite sharer
id class;
for(NSString *sharerId in favoriteSharers)
{
    class = NSClassFromString(sharerId);
    if ([class canShare])
    {
        [as addButtonWithTitle: [class sharerTitle] ];
        [as.sharers addObject:sharerId];
    }
}

// Add More button
[as addButtonWithTitle:SHKLocalizedString(@"More...")];

// Add Cancel button
[as addButtonWithTitle:SHKLocalizedString(@"Cancel")];
as.cancelButtonIndex = as.numberOfButtons -1;

return [as autorelease];
}

尚未覆盖showInView方法。

1 个答案:

答案 0 :(得分:2)

如果此视图控制器是配置了工具栏的UINavigationControllerUITabBarController的一部分,则需要在父控制器的视图中显示任何操作表。例如,[actionSheet showInView:self.navigationController.view];[actionSheet showInView:self.tabBarController.view];