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 07-22-2010, 01:44 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 4
tyler25 is on a distinguished road
Default Change UIScrollView contentSize

My iphone application has this main view which contains 2 scrollviews. The first scrollview contains some information (this one has paging enabled and user scrolls horizontally) and the second scrollview contains the tableview.

I am using UIScrollview to load tableView even though the tableView is a subclass of UIScrollview. This is because somehow I am not able to get tableview to scroll if I don't load it as a subview of UIScrollview. Is this a problem because of multiple scrollviews?

Since the call to get the data for the table is Async, I wait for the request to get data (I am using ASIHTTPRequest) and then update the tableView when data is available.

This works fine so long as the tableView returns data that fits in the UIScrollView contentSize that I had set when loading the UIScrollView. When the number of Rows increase, the scrollView is not able to load all of it. It cannot increase the content size. I have tried to set the contentSize when table is being reloaded but it won't make any difference.

Is there any way I can change the contentSize of the UIScrollView depending on the numberOfRows that are returned by the tableView? Is there anyway I can get tableView to scroll? I am stuck on this. Appreciate any help.

Here is the code snippet that I am using
HTML Code:
//UIScrollView and UITableView have retain properties and synthesize setup.
-(void)loadView{
        self.customTableView = [[CustomTableView alloc] init];
        self.tScrollView=[[UIScrollView alloc] initWithFrame:tableScrollViewFrame];
        self.tScrollView.contentSize=CGSizeMake(320,500);
    self.tScrollView.pagingEnabled = NO;
        self.tScrollView.showsHorizontalScrollIndicator = NO;
        self.tScrollView.showsVerticalScrollIndicator = NO;
        self.tScrollView.scrollsToTop = NO;
        self.tScrollView.delegate = self;
    self.tScrollView.autoresizesSubviews = YES;
        [self.tScrollView addSubview:customTableView.tableView];
}


-(void)didFinishLoadingData{
[self.customTableView reloadData];
}
tyler25 is offline   Reply With Quote
Old 07-22-2010, 10:06 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

Take the table view out of the scroll view. That's you're first mistake. Then we can figure out why the tableview is not scrolling.

It isnt "Wrong" per say, just unnecessary.
smithdale87 is offline   Reply With Quote
Old 07-22-2010, 01:06 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 4
tyler25 is on a distinguished road
Default

UITableView is out of the UIScrollView and here is the how it looks now:

-(void)loadView{
self.customTableView = [[CustomTableView alloc] init];
self.customTableView.tableView.frame = CGRectMake(0, 200, self.customTableView.tableView.frame.size.width, self.customTableViewe.tableView.frame.size.height) ;
self.customTableView.tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.rootView addSubview:customTableView.tableView];
}


-(void)didFinishLoadingData{
[self.customTableView reloadData];
}

Now, the problem is the table is displayed with the correct offset and the data is loaded and all of it is visible but I have to literally drag my mouse to see it. I am not able to scroll to the bottom to the last record.

I want the tableView to be loaded in the bottom half of the rootView. Where do I initialize the frame - in the subclass of UITableView (CustomTableView) or in the super class (RootView)? And how to make the frame size such that it actually updates the frame when more content is loaded.

Please let me know what is the correct way of doing it.
tyler25 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, uiscrollview, uitableview

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: 334
15 members and 319 guests
akphyo, alexP, appservice, bignoggins, EXOPTENDAELAX, flamingliquid, guusleijsten, Hamad, mariano_donati, Objective Zero, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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