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

  • Home
  • SEARCH
  • 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 8992511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:58:20+00:00 2026-06-15T22:58:20+00:00

I am working on a reader app. when you read one magazine, it will

  • 0

I am working on a reader app. when you read one magazine, it will display first five pages and download the rest pages one by one. there is a scrollview to view the thumbnail image of pages. At the beginning, if the page needs downloading, the corresponding thumbnail view’s alpha value is set to 0.5 (the thumbnail images are in the file,no need to download). when the page is downloaded, i will update the thumbnail view’s value to 1.0. I use one operation to download the page, and when one is downloaded i use delegate to set thumbnail view’s alpha.
But when i update thumbnail view’s alpha value, it still the same as the beginning. it seems the alpha has no effect. I wonder is there anything wrong with my code? some snippets are as follows:

In the PageViewController.m

- (void)loadView
{
   [super loadView];
   //...
   [self createSlideUpViewIfNecessary];
   [self downloadPages];
}
- (void)createSlideUpViewIfNecessary {
    if (!slideUpView) {
        [self createThumbScrollViewIfNecessary];

        // create container view that will hold scroll view and label
        CGRect frame = CGRectMake(CGRectGetMinX(self.view.bounds), CGRectGetMaxY(self.view.bounds), CGRectGetWidth(self.view.bounds), CGRectGetHeight(thumbScrollView.frame));
        slideUpView = [[UIView alloc] initWithFrame:frame];
        [slideUpView setBackgroundColor:[UIColor blackColor]];
        [slideUpView setOpaque:NO];
        [slideUpView setAlpha:0.75];
        [[self view] addSubview:slideUpView];

        // add subviews to container view
        [slideUpView addSubview:thumbScrollView];
    }
}

- (void)createThumbScrollViewIfNecessary {
    if (!thumbScrollView) {
        float scrollViewHeight = THUMB_HEIGHT + THUMB_V_PADDING;
        float scrollViewWidth  = CGRectGetWidth(self.view.bounds);
        thumbScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, scrollViewWidth, scrollViewHeight)];
        [thumbScrollView setCanCancelContentTouches:NO];
        [thumbScrollView setClipsToBounds:NO];

        // now place all the thumb views as subviews of the scroll view
        // and in the course of doing so calculate the content width
        float xPosition = THUMB_H_PADDING;

        for (int i = 0; i < magazine.pageNum ; i++) {
            Page *page = [magazine.pages objectAtIndex:i];
            NSString *name = page.pageName;

            NSString *mfjName =[name stringByReplacingOccurrencesOfString:@".mfj" withString:@"Small.mfj"];
            UIImage *thumbImage = nil;
            if([mfjName hasSuffix:@".mfj"])
                thumbImage = [Reader loadMfjFromSprOrCache:magazine MFJ:mfjName];

            ThumbImageView *thumbView;
            if (thumbImage) {// sometimes mfjname is 0 which means white page in normal and black thumbnail in thumbnail scrollview.
                if (!mThumbnailSizeUpdated) {
                    mThumbnailWidth = thumbImage.size.width;
                    mThumbnailHeight = thumbImage.size.height;
                    mThumbnailSizeUpdated = YES;
                }
                thumbView = [[ThumbImageView alloc] initWithImage:thumbImage];
            } else {
                CGRect thumbFrame;
                if (mThumbnailSizeUpdated) {
                    thumbFrame = CGRectMake(0, 0, mThumbnailWidth, mThumbnailHeight);
                } else {
                    mThumbnailWidth = 80;
                    mThumbnailHeight = 100;
                    thumbFrame = CGRectMake(0, 0, mThumbnailWidth, mThumbnailHeight);
                }
                thumbView = [[ThumbImageView alloc] initWithFrame:thumbFrame];
            }
            NSString *mfjPath= [[magazine getDownloadPath] stringByAppendingPathComponent:name];
            if (![magazine getFileInfo:name]&&![[NSFileManager defaultManager] fileExistsAtPath:mfjPath]) {
                thumbView.alpha = 0.5;
            }
            [thumbView setBackgroundColor:[UIColor blackColor]];
            [thumbView setTag:THUMBVIEW_OFFSET+i];
            [thumbView setDelegate:self];
            [thumbView setImageName:name];
            CGRect frame = [thumbView frame];
            frame.origin.y = THUMB_V_PADDING;
            frame.origin.x = xPosition;
            frame.size.width = frame.size.width+30;
            frame.size.height = frame.size.height+40;
            [thumbView setFrame:frame];
            [thumbScrollView addSubview:thumbView];
            UILabel *pageIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(xPosition, frame.origin.y+frame.size.height-THUMB_LABEL_HEIGHT, frame.size.width, THUMB_LABEL_HEIGHT)];
            [pageIndexLabel setBackgroundColor:[UIColor clearColor]];
            [pageIndexLabel setText:[NSString stringWithFormat:@"%d",(i+1)]];
            [pageIndexLabel setTextColor:[UIColor whiteColor]];
            [pageIndexLabel setTextAlignment:UITextAlignmentCenter];
            [thumbScrollView addSubview:pageIndexLabel];

            xPosition += (frame.size.width + THUMB_H_PADDING);
        }
        thumbScrollView.showsHorizontalScrollIndicator = NO;
        [thumbScrollView setContentSize:CGSizeMake(xPosition, scrollViewHeight)];
    }
}
- (void)downloadPages
{
   DownloadOperation *op = [[DownloadOperation alloc] initWithMagazine:magazine];
   op.delegate = self;
   [[(AppDelegate *)[[UIApplication sharedApplication] delegate] sharedOperationQueue] addOperation:op];
}

- (void)downloadOperation:(DownloadOperation *)operation finishedAtIndex:(NSUInteger)index
{
   if (thumbScrollView){
      [thumbScrollView viewWithTag:THUMBVIEW_OFFSET+index].alpha = 1.0;
   }
}

In DownloadOperation.m

- (void)main
{
   // ...
   NSUInteger index = 0;
   for (Page *page in mMagazine.pages)
   {
       if (/*page doesn't exist*/){
           // download the page;
           if ([delegate respondsToSelector:@selector(downloadOperation:finishedAtIndex:)]) {
                        [delegate downloadOperation:self finishedAtIndex:index];
            }
       }
       index++;
   }
}
  • 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-06-15T22:58:21+00:00Added an answer on June 15, 2026 at 10:58 pm

    you’re using operation queue to download images -> thus, your finish callbacks might arrive not on the main thread, but you are trying to update you UI anyway – try wrapping your UI interaction into dispatch_async on main thread:

     dispatch_async(dispatch_get_main_queue), ^{
         if (thumbScrollView){
             [thumbScrollView viewWithTag:THUMBVIEW_OFFSET+index].alpha = 1.0;
         }
     });
    

    Thanks to @Inafziger for clues on this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, all. Working on my first Rails app. I've searched all around - read
I am working on pdf reader app.i am using gestures for rendering next page
Now I am working on an application. Through my app users can read pdf
I'm working on a Win 8 javascript app that has rss-reader-like capabilities. It should
I am working on a bookmarking feature for a book reader iOS app I
I'm working on an RSS reader app for Android. I have it to where
I am working on an Android app that needs to read a line from
I am working on an android application which is sort of an e-reader but
I am working on one application in which I am getting conflicted render result
I`m working on an app that does reading and handling specific URIs from NFC

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.