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 8055849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:31:26+00:00 2026-06-05T08:31:26+00:00

I want to display some TTImageView in a TTScrollView . – (UIView*)scrollView:(TTScrollView*)scrollView pageAtIndex:(NSInteger)pageIndex {

  • 0

I want to display some TTImageView in a TTScrollView.

- (UIView*)scrollView:(TTScrollView*)scrollView pageAtIndex:(NSInteger)pageIndex {

TTView* pageView = nil;
if (!pageView) {
    pageView = [[[TTView alloc] init] autorelease];
    pageView.backgroundColor = [UIColor clearColor];
    pageView.userInteractionEnabled = NO;
}

NSString *imagePath = [self.screenShotImgPath objectAtIndex:pageIndex];
TTImageView *imageView = [[[TTImageView alloc] initWithFrame:CGRectZero] autorelease];
imageView.autoresizesToImage = YES;
imageView.urlPath = imagePath;
imageView.backgroundColor = [UIColor clearColor];
imageView.delegate = self;


//here I need to rotate image
if (imageView.width > imageView.height){
    CGAffineTransform  tran = CGAffineTransformIdentity;
    CGSize             bnds = imageView.size;
    CGSize             bnds2 = imageView.size;
    bnds = [self swapWidthAndHeight:bnds];
    tran = CGAffineTransformMakeTranslation(0.0,bnds2.width);
    tran = CGAffineTransformRotate(tran, [self degreesToRadians:-90.0]);
    imageView.transform = tran;

}

//here I need to scale image view frame to fit image actual scale
CGFloat scale = imageView.width/imageView.height;
CGFloat scaledWidth = (scrollView.height - 20.f) * scale;
imageView.frame = CGRectMake((scrollView.width - scaledWidth)/2, 10.f, scaledWidth, scrollView.height - 20.f);
[pageView addSubview:imageView];
return pageView;
}

but there is a problem: TTImageView download image asynchronously. So it is quit possible that when code go to

 if (imageView.width > imageView.height){

this line the image is not loaded. So a exception is thrown.

Since the image view is added in

- (UIView*)scrollView:(TTScrollView*)scrollView pageAtIndex:(NSInteger)pageIndex {

so I can’t move the below rotate code out of this method

  if (imageView.width > imageView.height){
    CGAffineTransform  tran = CGAffineTransformIdentity;
    CGSize             bnds = imageView.size;
    CGSize             bnds2 = imageView.size;
    bnds = [self swapWidthAndHeight:bnds];
    tran = CGAffineTransformMakeTranslation(0.0,bnds2.width);
    tran = CGAffineTransformRotate(tran, [self degreesToRadians:-90.0]);
    imageView.transform = tran;
   }

What I can do to solove this problem?

  • 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-05T08:31:28+00:00Added an answer on June 5, 2026 at 8:31 am

    You can add a <TTImageViewDelegate> in your .h file
    and this function in the .m:

    #pragma mark TTImageViewDelegate
    -(void) imageView:(TTImageView *)imageView didLoadImage:(UIImage *)image{      
        if (image){
            //do your logic
        }
    }
    

    This function will be triggered when the image is finished loading.

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

Sidebar

Related Questions

I want to display some content through views and to theme accordingly I have
I want to display some kind of animation when my datagrid is updating. Does
I want to display some text on twitter/facebook when a link is clicked on
I want to display some text for a few seconds and then quit my
Hi everybody i want to display some HTML file in a visual basic 6
When I want to display some data in the web, the data need makeup,
For the most part, when I want to display some HTML code to be
I am totally new to xcode. I want to display some text in Detail
I am new to sencha touch2. i want to display some text labels below
I'm a newbie with SQL... Now I want to display some instances of AddrDistances

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.