Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bradnet

macrumors newbie
Original poster
Mar 8, 2010
20
0
Hi Guys

Got a little question that someone may have a simple answer for, i'm using tableview to open a detail view with a scrollview containing an image that could be larger than the page, here is the line that i added

Code:
[scrollView setContentSize:CGSizeMake(320, _image.bounds.size.height)];

using this method the view wont scroll but if i manually specify the height it will scroll fine

Code:
[scrollView setContentSize:CGSizeMake(320, 550)];

my problem is that not all of my images will be 550 heigh some might be over 1000 does anyone know why this isn't working.

Thanks
Brad
 
Last edited by a moderator:
Use NSLog to log the image view height when you are using it to set the scrollview content size. It may not be what you expect...
 
I've checked the NSLog and the size it's outputting is the size of the imageview on the interfacebuilder screen but i want this size to be dynamic to the size of the image i thought this was the correct method.

Thanks
Brad
 
Is there anyway you can point me in the right direction i have an image downloaded from a url and displayed on the screen which is sometimes longer than the screen so i have the mediaURL how would i reference the url to get the image height. is it an NSUrl request.

Thanks
Brad
 
managed to solve this problem but in order to do it i had to load the data from the url into a nsdata and then load this data into a uiimage and then measure the UIImage.

Here's the code to help any others out
Code:
NSString * mediaUrl = [[[self appDelegate]currentlySelectedBlogItem]mediaUrl];
NSData* imageData;
imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mediaUrl]];			
UIImage * imageFromImageData = [[UIImage alloc] initWithData:imageData];
NSLog(@"DetailScreen applicationFrameSize: %.0f", imageFromImageData.size.height);
[scrollView setContentSize:CGSizeMake(320, imageFromImageData.size.height)];

Thanks
for the help
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.