Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-12-2011, 07:02 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Location: Turkey
Posts: 157
erdinc27 is on a distinguished road
Default UIImageView with ScrollView

i have an array with links of images. and i want to add them to my scrollView.i wrote that codes for that but it doesnt show anything. how i can do that ?
Code:
- (void)scrollViewDidScroll:(UIScrollView *)_scrollView {

	
	scrscroll.delegate = self;
	
	scrscroll.indicatorStyle = UIScrollViewIndicatorStyleDefault;
	scrscroll.clipsToBounds = YES;
	scrscroll.scrollEnabled = YES;
	scrscroll.pagingEnabled = YES;
	int i=0;
	CGFloat cx = 0;
	for ( ; i< [buyukResimLink count] ;i++)
	{
		UIImage *image = [UIImage imageWithData:[[NSData alloc] initWithContentsOfURL:[[NSURL alloc] initWithString:[buyukResimLink objectAtIndex:i]]]];
	
		UIImageView *resimView=[[UIImageView alloc] initWithImage:image];
		CGRect rect = resimView.frame;
		rect.size.height = image.size.height;
		rect.size.width = image.size.width;
		rect.origin.x = ((scrscroll.frame.size.width - image.size.width) / 2) + cx;
		rect.origin.y = ((scrscroll.frame.size.height - image.size.height) / 2);
		resimView.frame=rect;
		
		[scrscroll addSubview:resimView];
		[resimView	release];
		cx += scrscroll.frame.size.width;
	}
}
erdinc27 is offline   Reply With Quote
Old 09-12-2011, 09:09 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

I don't see anywhere that you are setting the contentSize property for the scrollveiw?


On a side note: there are several memory leaks here
Code:
UIImage *image = [UIImage imageWithData:[[NSData alloc] initWithContentsOfURL:[[NSURL alloc] initWithString:[buyukResimLink objectAtIndex:i]]]];
Also, depending on what buyukReseimLink objectAtIndex:i is, if it's a remote URL, then there is gonna be a huge delay in each of these images downloading synchronously like this. Depending on their size, it could take a while before they are downloaded and anything shows up on your screen.
smithdale87 is offline   Reply With Quote
Old 09-12-2011, 09:46 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Location: Turkey
Posts: 157
erdinc27 is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
I don't see anywhere that you are setting the contentSize property for the scrollveiw?


On a side note: there are several memory leaks here
Code:
UIImage *image = [UIImage imageWithData:[[NSData alloc] initWithContentsOfURL:[[NSURL alloc] initWithString:[buyukResimLink objectAtIndex:i]]]];
Also, depending on what buyukReseimLink objectAtIndex:i is, if it's a remote URL, then there is gonna be a huge delay in each of these images downloading synchronously like this. Depending on their size, it could take a while before they are downloaded and anything shows up on your screen.
i wrote that in viewDidLoad like here
Code:
[scrscroll setContentSize: CGSizeMake(scrscroll.bounds.size.width * [buyukResimLink count], scrscroll.bounds.size.height)] ;
but my mistake was i didnt write this
Code:
scrscroll.delegate=self;
after that it works now. thanks for help and answer.
erdinc27 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 407
10 members and 397 guests
7twenty7, apatsufas, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0