Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7631705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:25:22+00:00 2026-05-31T06:25:22+00:00

I am using this as a bit of a blueprint for setting up a

  • 0

I am using this as a bit of a blueprint for setting up a block based action sheet. My actions for the action sheet are Cancel, Download, and Stream. I changed the BlockBasedActionSheet.h to:

 @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

and the BlockBasedActionSheet.m to:

@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 == 0) {
    if (self.cancelBlock) {
        self.cancelBlock();
    }
}
if (buttonIndex == 1) {
    if (self.downloadBlock) {
        self.downloadBlock();
    }
}
if (buttonIndex == 2) {
    if (self.streamBlock) {
        self.streamBlock();
    }
}
}

@end

In my TableView didSelectRowAtIndexPath, I put the following:

    BlockBasedActionSheet *askSheet =
    [[BlockBasedActionSheet alloc] 
     initWithTitle:@"What Do You Want To Do" cancelButtonTitle:@"Cancel" downloadButtonTitle:@"Download" streamButtonTitle:@"Stream" cancelAction:^ {

 }downloadAction:^ {

     UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
     CGRect frame = CGRectMake(0, 49, 160, 50);
     progress = [[UIProgressView alloc] initWithFrame:frame];
     cell.contentView.tag = 100;
     [cell.contentView addSubview:progress];
     RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
     NSURL *url = [NSURL URLWithString:entry.articleUrl];    
     self.nameit = entry.articleTitle;
     NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
     receivedData = [[NSMutableData alloc] initWithLength:0];
     NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];

 }streamAction:^ {
     if (_webViewController == nil) {
         self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
     }
     RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
     _webViewController.entry = entry;
     [self.navigationController pushViewController:_webViewController animated:YES];
 }];
[askSheet showInView:self.tabBarController.view];
[askSheet release];

The Action Sheet Presents from top to bottom:
Download
Stream
Cancel

When I press Download, the Cancel action performs;
Stream, the Download action performs;
Cancel, the Stream Action performs

What have I done wrong that it is getting out of order?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:25:23+00:00Added an answer on May 31, 2026 at 6:25 am

    try this:

    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();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app
I'm using this bit of jQ to add a class to two different elements
I'm using this bit of code to display the number of users on a
I'm using this bit of code to capture the iPad screen. I keep getting
I'm using this bit of code to add a CSS link in the head
I am using this bit of jQuery code to get href of the link:
I am using this bit of jQuery: $('.myClass').html().replace(-, &#x2011;); to replace hyphens with non-breaking
I'm using this bit of code to hide a menu bar when users scroll
I am using this wonderful bit of code created by jackreichert . This in
I'm using this bit of jQuery code to target Safari: if ($.browser.safari) { $('#div1').css({'margin-top':

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.