ActionSheet不会在iPad中显示

时间:2017-02-17 18:40:39

标签: ios iphone ipad uiactionsheet

自从iOS 10.2.1以来,我在iPad上出现了UIActionSheets的问题。在iPhone上它们显示得很好,但在iPad上没有任何事情发生,使用相同的代码。我将ActionSheet子类化,因此我可以使用BlockBased。这是标题:

@interface BlockBasedActionSheet : UIActionSheet<UIActionSheetDelegate> {
}

@property (copy) void (^cancelBlock)();
@property (copy) void (^downloadBlock)();
@property (copy) void (^streamBlock)();


- (id)initWithTitle:(NSString *)title cancelButtonTitle:(NSString *)cancelButtonTitle downloadButtonTitle:(NSString *)downloadButtonTitle streamButtonTitle:(NSString *)streamButtonTitle cancelAction:(void (^)())cancelBlock downloadAction:(void (^)())downloadBlock streamAction:(void (^)())streamBlock;

@end

执行文件:

#import "BlockBasedActionSheet.h"
@implementation BlockBasedActionSheet
@synthesize cancelBlock = _cancelBlock, streamBlock = _streamBlock, downloadBlock = _downloadBlock;

- (id)initWithTitle:(NSString *)title cancelButtonTitle:(NSString *)cancelButtonTitle downloadButtonTitle:(NSString *)downloadButtonTitle streamButtonTitle:(NSString *)streamButtonTitle cancelAction:(void (^)())cancelBlock downloadAction:(void (^)())downloadBlock streamAction:(void (^)())streamBlock
{
    self = [super initWithTitle:title delegate:self cancelButtonTitle:cancelButtonTitle destructiveButtonTitle:nil otherButtonTitles:downloadButtonTitle, streamButtonTitle, nil];
    if (self) {
        _cancelBlock = Block_copy(cancelBlock);
        _downloadBlock = Block_copy(downloadBlock);
        _streamBlock = Block_copy(streamBlock);
    }
    return self;
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSAssert(actionSheet == self, @"Wrong Action Sheet passed");
    if (buttonIndex == [self cancelButtonIndex]) {
        if (self.cancelBlock) {
            self.cancelBlock();
        }
    }
    if (buttonIndex == [self firstOtherButtonIndex]) {
        if (self.downloadBlock) {
            self.downloadBlock();
        }
    }
    if (buttonIndex == [self firstOtherButtonIndex] +1) {
        if (self.streamBlock) {
            self.streamBlock();
        }
    }

}

@end

我在视频控制器中运行它,我需要它:

BlockBasedActionSheet *askSheet =
    [[BlockBasedActionSheet alloc] 
     initWithTitle:@"What Do You Want To Do" cancelButtonTitle:@"Cancel" downloadButtonTitle:@"Download" streamButtonTitle:@"Stream" cancelAction:^ {
         [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
     }downloadAction:^ {
}];
streamAction:^ {
}];
[askSheet showInView:self.tabBarController.view];
    [askSheet release];

为什么这不会在iPad上运行?

0 个答案:

没有答案