I can't understand... it was used to work before in other Apps I made with older IOS framework
Check the code below:
If I changed the contentMode to Left it displays the image...
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
IBOutlet UIScrollView* scrBook;
}
@property (nonatomic, retain) IBOutlet UIScrollView* scrBook;
@end
@synthesize scrBook;
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame;
frame.origin.x = 0;
frame.origin.y = 0;
frame.size = self.scrBook.frame.size;
UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
//subview.contentMode = UIViewContentModeLeft;
subview.contentMode = UIViewContentModeScaleAspectFit;
UIImage *currentImage = [UIImage alloc];
currentImage = [UIImage imageNamed:@"model.jpg"];
subview.image = currentImage;
[self.scrBook addSubview:subview];
self.scrBook.contentSize
= CGSizeMake(self.scrBook.frame.size.width * 1, self.scrBook.frame.size.height);
}
UIViewContentModeLeft:
UIViewContentModeScaleAspectFit:
Updates: My last attempt was to uddate xcode to 4.5.2 and it doesn't work either, frustrating ...
Not the answer to your problem, just a few optimizations...
UIImage *currentImage = [UIImage alloc];
currentImage = [UIImage imageNamed:@"model.jpg"];
There is no need for the first line, just do this:
UIImage *currentImage = [UIImage imageNamed:@"model.jpg"];
Also,
self.scrBook.contentSize
= CGSizeMake(self.scrBook.frame.size.width * 1, self.scrBook.frame.size.height);
can just be...
self.scrBook.contentSize = self.srcBook.frame.size;
I found a solution but still don't know the reason, I upgraded my XCode to 4.5.1 to 4.5.2 and still nothing.
I duplicated one old project made in an older version of xcode (older than 4.5.1) using the 4.5.2 with the exaclty same code and it worked fine....
very weird.. I feel bad I took so many hours trying to find a solution...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.