in my app I have a uiview with a tableview inside of it. This tableview consists of only one cell which is rather high (ca. 750) and contains alot of objects (uitextfields, uitextview, images, buttons, uiscrollview, smaller uitableview, etc).
I'm experiencing a small stuttering when scrolling the tableviewcell which I can't seem to get rid of.
Is it the large amounts of objects in one cell or should I distribute the objects into multiple cells to get rid of the stuttering?
Would be great if somebody has experienced the same issue and could help me out here a little.
Thanks a lot!
I tried this trick with tableHeaderView - works perfect for me! I'm also have a large hierarchy of subviews. ALso if you need some easy custom UI elements appearance/disappearance animations you can divide it into different cells. I love doing like that because of UITextViews and UITextFields - UITableViewController makes layout for keyboard appearance automatically.
Related
I want to scrolltableview horizontally as well as vertically. How can I do it?
I'd suggest making a UIScrollView the same size as the screen and then making your UITableView bigger than the screen.Drop the TableView into the ScrollView. Set up the scrollview with a high contenSize.width and then tweak it to work as you desire.
The idea with embedding UITableView into UIScrollView seems to be great, however there is a serious gotcha. UITableView is optimized to display only visible viewpoirt area and limiting allocated UITableView cells. In the case it is embedded into UIScrollView, it allocates complete content area of scroll view, i.e. all rows for the UITableView. It goes out of the memory for approximatelly 2000 rows. Since the UITableView.reloadData creates callback in main thread, it blocks main thread to respond to didReceiveMemoryWarning and application is killed on system sole discretion for level 2 warning, which is never received.
It seems that the better way is in subclassing UITableView and extending rows to width which can be scrolled horizontally.
If you are looking for something similar to what is done in 'Pulse', then this tutorial might help you:
http://iosstuff.wordpress.com/2011/06/29/creating-pulse-style-scrolling-horizontally-scrolling-uitableview-as-a-subview-of-uitableviewcell/
It shows how to add a horizontally scrolling UITableView to a vertically scrolling UITableView
So I have a UITableViewController. The cells in this tableview have the following UIControls:
2 UILabels, one of which has a shadow and a clearColor background color.
1 Custom Progress view resized to be larger and with a different color
3 UIButtons
Functionally, they do exactly what they are supposed to do. However, I've noticed when looking at it on device that scrolling performance quickly tanks and has dropped frames all over the place, even with other interactions like pushing one of the buttons.
So I was reading around today and found http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/ this article by the Tweetie guy about how to achieve fast scrolling performance by subclassing UITableViewCell and doing the drawing yourself.
The example works extremely well, but when I tried to adapt it to work with my desired configuration I realized that he isn't using any predefined UI Controls, he's mapping out everything by hand.
While I can see how this would be an extremely efficient way to do things, it strikes me as problematic for things like the progress view and the buttons, and even one of my labels to a certain extent.
So my question is this: Do I need to completely write my controls from scratch if I want my scrolling performance to be good, or is there a way to use the standard UI Controls and get good scrolling performance?
If you're adding custom controls to your cell, you should still be subclassing UITableViewCell, adding your controls in the init function, laying them out in layoutSubviews, etc. - just like any other view. As VdesmedT says, make sure you're re-using cells via the dequeue mechanism, so that you aren't allocating new cells with each scrolling operation.
OK, I will propose something obvious but to achieve UIScrollView performance, you need to be sure that the dequeue mechanism works well. I often see developers not properly set the identifier in IB and therefore missing the UITableViewCell cache benefit
I have a UIScrollView that I am using to simulate a UITableView like interaction because rows are a bit more complex than what UITableView has to offer. I have 4 UILables a UIImageView and a UIButton for every row. The end result is a lot of subviews.
Even with only 10 rows,the scroll view that looks fine in the simulator but has a fairly low frame rate on the iPhone 4. This is a resource consumption issue for sure.
Is there a way to optimize the redraw durring scrolling like double buffering?
If not is there another way to get customizable UITableview functionality?
thanks
Does every View have 4xUILabels, a UIImageView and a UIButton?
I would create a nib file with a custom UITableViewCell (You can make those as complex as you want), then you can reuse the cells to help with your performance.
Information on how to do this is here:
http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW1
I think you probably want to create a custom subclass of a UITableViewCell as the UITableView will handle all the redrawing for you. In a custom UITableViewCell you can add as many subviews as you like.
Take a look at http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html.
UITableViews are subclasses of UIScrollView (or at least conform to their behavior), but you really want to let the iPhone handle the selective drawing/cell reuse for you that the UITableView provides.
You should use UITableView if it does everything you need.
However if your tableview cells are really complicated, or you want to enable paging on the scrollview, you should take a look at the PageContol sample code that Apple provides. In a nutshell, you watch for movement in scrollViewDidScroll: and load new "pages" just before they become visible. This method works very well in practice for arbitrarily long lists of pages.
I've started implementing a UIScrollView that will contain many thumbnail-sized pictures and will scroll only horizontally. For this, I keep a limited number of UIImageViews created and remove/add them to the UIScrollView as the user scrolls it.
The problem is I need to find a way to optimize it as scrolling sometimes gets sluggish. Maybe it's the adding/removing from the view, I don't know.
I figure this is a common component that might have been implemented more than once, but I couldn't find any library that featured something like this. If there is something ready available, I wouldn't need to spend many hours fine tuning or figuring out how to improve my component.
This is different from the question that has been asked here many times: I don't want it to behave like the photos app. I want many pictures to be visible at a time and to scroll them smoothly, without "hard pages".
So, anyone know of a component which does something similar to this?
I managed to do something similar by using a rotated UITableView instead:
UITableView *tableView = [[UITableView alloc] initWithFrame:...];
tableView.transform = CGAffineTransformMakeRotation( -M_PI/2 );
You can then configure your UITableViewCells to display the images. You can also rotate the UITableViewCell contentsView.
I made a two dimensional scrolling component called DTGridView. You can use it with just the one row to make a purely horizontal scroll view. It has an API much like UITableView, where you have a dataSource and a delegate to tell it how many rows/columns etc and to handle touch events for the cells.
It also uses a method of cell reuse like UITableView does to save on memory. If you aren't using cell reuse on table views, you should be. :)
I've been working with a UIScrollView and have about 200 items to scroll through...so far. This doesn't work since it takes around 45 seconds to load all of the views. I've tried loading the first 20 (about 4 seconds) on the main thread then load in blocks of 50 on other threads. I get the first 20 to scroll through but the others don't appear.
It's taken lots of effort just to get the UIScrollView to work properly and there are still some issues. The UITableView will solve all of this for me since it reuses cells. It's similar to the UIScrollView except more efficient.
I'd like to have one cell take up the entire viewing area and have the user flick through each cell. Rather than freely scrolling through cells, scrolling will stop at each cell and the user must flick again for the next cell. The UITableView doesn't do this that I know of. Is there a way to get this behavior with a UITableView?
UITableView is a subclass of UIScrollView. Have you tried simply setting yourTableView.pagingEnabled = YES?
Short answer: no.
You can try to control UITableView's scrolling behavior using the delegate methods, or better yet, stick with UIScrollView and load the views one-by-one in the UIScrollViewDelegate methods.