UITableView not scrolling smoothly-(iPhone SDK) ..!

UITableView not scrolling smoothly...(iPhone SDK) ..!!

I have implemented UITableView DataSource and Delegate methods in an individual separate classes.(one for delegate and one for datasource) in main program i write only:

//assume that all objects are allocated ObjTableView.dataSource=ObjDataSource; ObjTableView.delegate = ObjDelegate; [self.view addSubView: ObjTableView];

when i run this code , UITable view appears but when i try to scroll it, it doesn't scroll smoothly. I have also checked that UITableViewCell doesn't redraw once the cell is initialized.

can any one tell me why this happens ? How can i solve this problem ??

From comments:

ListDataSource *ObjListDataSource = [[ListDataSource alloc]initWithArray:[[sender object] valueForKey:@"List"]]; ListDelegate *ObjListDelegate = [[ListDelegate alloc]initWithArray:[[sender object] valueForKey:@"List"]]; tblList = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)]; tblList.dataSource = ObjListDataSource; tblList.delegate = ObjListDelegate; [self.view addSubview:tblList]; [tblShopList release];

More from comments:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = [NSString stringWithFormat:@"%i",indexPath.row]; UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,320,100) reuseIdentifier:CellIdentifier] autorelease]; //custom cell code } return cell; }

More Information:

I have used NSNotification which notifies to current class when parsing is complete, after receiving notification , current class method calls DataSource, Delegate methods (which is defined in a separate class file).

So UItableViewCell customization (which is in ListDataSource) and table view(in current class) both are in different classes.


A problem is

NSString *CellIdentifier = [NSString stringWithFormat:@"%i",indexPath.row];

The id needs to be the same for all cells of the same class, otherwise you never reuse them. As you can see in most examples, it is indeed a constant in most (all?) cases.

Little explaination on the reuseIdentifier: every time a cell gets out of screen, you can reuse it instead of creating a new one. To reuse it, you need a cell in queue with the same identifier as the one you pass to dequeueReusableCellWithIdentifier. The way you did, the cells are never reused, because each id is unique (they may or may not be reused in case a row reappears on screen, depending on queue size, which is not configurable AFAIK). This is why personalization of the cell should happen OUTSIDE the "cell == nil" block. Long story short, you are using the reuseIdentifier not as intendend.

I think Michele is correct, but I would also add that it looks like you are doing your cell customization where the cell gets created. What you should be doing is something more like this:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = (UITableViewCell)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,320,100) reuseIdentifier:CellIdentifier] autorelease];
//custom REUSABLE cell code here, e.g. text color, etc.

NSString *cellText = [dataArray objectAtIndex:indexPath.row]; //assuming you have a simple array for your data

cell.textLabel.text = cellText;

return cell;

I would also add that I'm not sure why you are able to run the app with the code you have here, since UITableViewCell cell = ... is an invalid initializer. It should be UITableViewCell *cell = ....

It would be helpful to see how you are customizing your cell, since without that it's hard to see what's happening.

Category:iphone Time:2010-10-18 Views:1
Tags: iphone

Related post

  • UITableView LoadMore options in iphone sdk 2011-01-24

    How to create a cell in UItableView which will display as "Load more data..."? When clicked, this cell will add some more data. Similar to Twitter and Facebook. Any source code will help a lot... Thanks for your help... --------------Solutions-------

  • UITableview not scrolling smoothly 2012-02-10

    I have UITableView in my application & have created tableview cell normally with creating any class file. In my table cell i'm adding UITextview due to which my UITableView is " not scrolling smoothly ". After I comment textview code or replaces

  • Graphic scrolling in iPhone SDK 2010-07-16

    I have a graphic that is 3 times the width of an iphone landscape view. I am trying to auto scroll it so that it appears that it is moving sideways, without using the touchscreen scrolling method. My aim is to maybe have a button you can press and it

  • How to create a tableView with multiple column structure and horizontal scroll in iPhone SDK? 2011-01-25

    In my iPhone app, I am having a requirement of putting a tableView that is similar to GridView. How can we create and implement it? Please Help and Suggest Thanks --------------Solutions------------- As Simon mentioned... I don't think a tableView wo

  • How to Play sound when UIScrollView is scrolling in iphone sdk? 2011-09-22

    I have a scroll view that can be scrolled to the sides (only up and down, not left and right). I want to play a short sound, whenever the scroll view is moved Y pixels to either side. How can this be done? Code samples will be greatly appreciated...a

  • UITableView editing-mode problems (iPhone SDK) 2009-09-12

    I have a tableView populated with custom tableViewCells. The cells are not subclasses, they are merely tableViewCells which have had a lot of tweaking and "subview-adding"(done in the cellForRowAtIndexPath method). The problem occurs when i tap the e

  • Help me to complete my UITableView to Navigation Controller [iPhone SDK] 2009-12-31

    I built an application. On the one my views I used TableView. So now I want to change this Table view to a navigation controller. 1- How can I change UITable view to Navigation Controller. I add navigation codes but I got some alert! [I know I must i

  • ALAssetsLibrary, NSMutable Array and UITableview lazy scrolling? 2012-02-14

    I am trying to implement an application based on the ALAssetsLibrary fetching all image and video from photo library in ios4. I stored ALAsset into the NSMutableArray(assets),and then i display all video/photo thumnail in the tableview cell. Now the

  • disable scrolling in a UITableView (iPhone SDK 3.0) 2009-08-06

    I'm trying to disable scrolling in a UITableView when editing a UITextField embedded in a UITableViewCell. This is just to prevent the cell from being scrolled out of sight when edited (and also to avoid some related cell "Recycling" problems). While

  • iPhone SDK: Load Tweets into UITableView? 2010-06-26

    I need to include a Twitter-Feature with the Tweets of my account, but I don't know how I can get my tweets and show it in a UItableView? Please Help.. Thanks. --------------Solutions------------- Here is a great article on getting it done with JSON.

  • iPhone SDK Scrolling Game Area with Dragging Cards 2010-09-10

    We are starting a new game and while I have a few months experience with iPhone SDK, I'm not quite sure the best approach to take for this project. Basically, our card game requires more real estate than the iPhone screen allows. What we ultimately n

  • UITableView - Grouped Table. iPhone SDK (Cocoa Touch), Objective C 2011-09-29

    I found this realy nice tutorial: UITableView – Drill down table view tutorial, source code: download. This is exactly what I was looking for, but I would like to add a little upgrade. My goal is to add grouped table view with 2 sections in level 0 (

  • Custom UITableView with UITextview is not scrolling smoothly in ios device 2013-08-22

    I tried to load dynamic images in imageview and text in label ,its working fine in both simulator and ios device. (see below code) - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ImageCell *cel

  • How to know when UITableView did scroll to bottom in iPhone 2011-02-28

    I would like to know when a UITableView did scroll to bottom in order to load and show more content, something like a delegate or something else to let the controller know when the table did scroll to bottom. Does anyone know this, please help me, th

  • iPhone SDK: UITableview Dynamic Content 2011-11-09

    I have a UITableview setup in my iphone app. At the moment, each row is populated with items from an NSMutableArray. The array gets data from a mysql database which I have to update myself in order to update the contents of the tableview. I'm trying

  • Why won't UITableView 'Auto-scroll' when editing UITextField (in UITableViewCell)? (iPhone) 2012-02-12

    I have created a UITableView that is of type UITableViewStyleGrouped. I have then created several different sections with a few rows in each. Within each of these rows I have created a custom UITableViewCell that contains a UITextField. I also have o

  • How to implement a search bar that stays always on top using UISearchDisplayController in iPhone SDK 3.0 2009-07-31

    The iPhone SDK 3.0 has this handy new class "UISearchDisplayController" which makes it easy to create a search bar, handling all the user input and displaying the search results. I am using it for my new app, but there is one thing i would like to ch

  • Is it possible to be notified when a UITableView finishes scrolling? 2010-03-01

    I referenced this question: http://stackoverflow.com/questions/993280/how-to-detect-when-a-uiscrollview-has-finished-scrolling UITablewView is a subclass of UIScrollView, and my UITableView delegate does get the - (void)scrollViewDidEndDecelerating:(

  • Display large PDF using iPhone SDK 2010-05-03

    I was wondering what is the best way to display a big PDF file (it's a map actually) using iPhone SDK (the file is around 5MB), because it's really slow in a UIWebView. I want to be able to scroll through the PDF and zoom in/out. Also do you think th

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.590 (s). 13 q(s)