I've finally finished my first large application, the only problem is that I've focued a lot on design, and I'm using custom nibs as cells with transparent backgrounds. When I tried testing the application on my iPhone, the performance was terrible.
Is there any way to get better scrolling performance while using transparent cells with a ImageView behind the UITableView?
I've read two articles mostly:
blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/
cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
Looks good, but what if I want to use transparent cells?
a) Uses solid color.
b) Uses imageview as background.
Any help will be greatly appreciated. I want to get this baby released as soon as possible, but the performance as it is now is terrible!
First off, stop using nibs. Every time a cell is created, you're now hitting the disk in order to unarchive the nib. 3.1 will actually make this better, but until then, please create your cell in code.
Secondly, remove transparency wherever you can. Anything that doesn't need to be transparent, shouldn't be. And anything that isn't transparent should have the opaque property set to YES.
A third suggestion is if you're using a lot of subviews, you will see a performance benefit by using a custom view to draw everything instead of a bunch of subviews. If you choose to go this route, you should consider how it behaves when rotating to landscape mode (e.g. how the stretch action occurs), or if you have any controls that need to handle touches separately from the cell itself.
Related
I want the background image to only be visible where the individual cells are, so as you scroll it reveals different parts of a fixed image underneath. It's basically the opposite of a common tableview with opaque cells over a background, if that makes sense.
I still want the cells to be rendered normally in addition to their edge serving as a mask boundary, since they'd have text and other subviews that aren't just for masking.
I can't find an example, but I've seen this effect before done using CSS and it looks nice. It's not incredibly complicated, but I can't seem to figure out an efficient way to do it in UIKit.
This is end end result I want:
And this is the thing I tried initially.
This does not work, the cells below/above the cell with the background will overlap or underlap the background depending on when they are added into the tableview (like via dequeue/scrolling).
I am quite OK with this not working, and I believe I can achieve it by other means. For example by adding these backgrounds as views within the tableview itself and moving them based on the content offset or similar ways, maybe adding a background image that is tall with them embedded.
But. I am curious if there are some easier way, just adding the view into the XIB and applying a rotation would be very nice.
The background should be below the text in the other cells as well - this is where the complications comes in.
Anyway. Is this possible in some super-neat way?
What you should do is setting all cell's background to clear, and to set a background to your UITableView or your UIView.
Or, as you suggest, you can add a UIView with a rotation applied, and add it as a subview of your UIView/UITableView, and send it to back with [self.view sendSubviewToBack:backgroundView].
I have a table view with custom cells and I am trying to optimize it to make the scrolling as smooth as possible. I've followed most of the advises about table view optimization, for example, using fixed heights, not using AutoLayout etc.
I have achieved in a very optimized state except one thing. The custom cell has one image and several UILabels. With one image & 3 labels, the performance is perfect. However, when I add the 4th label, I start to observe a bit of jerkiness, very small but not as smooth as before.
I have searched the net and found CoreText can help performance. Is CoreText a right direction? Are there any other things that can help to improve UILabel performance when used in a table view?
EDIT:
I only use simple functions for UILabel by setting its font, font color, text and numberOfLines.
Core text is probably the ultimate solution for performance, but even before getting there I like to use a program called PaintCode to draw up the contents of my cells if they are particularly complicated.
Other things you can do however to speed things up a bit before you need to get to that point:
Do all calculations before cellForRow is called. So any number formatting, date calculations etc, should all be done and stored on your model object beforehand. That way you can just plug them straight in to your cells properties and they're ready to be displayed. Any extra time spent in cellForRow will slow down your tableview.
Set all labels and views to opaque. You'll probably have to set their background color when you do this, but it makes drawing the views that much faster. You can see which views have transparency applied by turning on "Color Blended Layers" from the debug menu for the simulator. What you want is to have your cells completely green.
Keep some dummy text in all labels by default. Updating text would not cost memory.
CoreText is pretty expensive and probably not meant for this! I think dummy text tricks should work for you.
Hope this works.
I've been searching through here and googling like crazy for a possible solution to this problem. Thus far I'm turning up exactly nothing that actually fixes it so I'm hoping someone can help.
I'm working on the UI for a iPad app. I'm doing it using interface builder. I worked with storyboards briefly but I don't like them all that much so I'm sticking with IB for now. Unfortunately I'm not very experienced with the workings of IOS Ui but it's been going relatively smoothly so far. In my app, I have a view controller, which holds a view containing a pair of sub views. One subview contains a rather windows like header bar (i like the look). The second contains a UITableView. The UITableView is set up properly as far as I can tell, and feeds it's info from a data source using custom UITableViewCells. The UITableView is set to grouped though currently there is only one section. The table is in edit mode by default because I want the user to be able to add new items and use the VC as a selection dialog. The view controller is presented (rather than pushed) using UIModalPresentationFormSheet (again, because I like the view) but I don't know that has any bearing on the problem. The cell border is flush with the X origin, the only reason the text isn't currently starting there is because I went into my cell and move the label over, leaving a gap between the edge of the cell and the label containing my text.
The Offending View http://bit.ly/144cbjT
The Problem: The UITableViewCells, for some reason are positioning themselves at X: 0. This puts them outside the border drawn on the UITablewView when you set it to grouped style. I could probably just turn off the border and get away with it, but I like the look so i want to keep it. I've tried messing around with constraints and anchor points on the cells, the content of the cells, the table itself, the view... I've tried simply moving my cell's labels over a bit. I've also had clipping subviews turned on and off. I've made sure the controls are being loaded properly from the XIB. I've made sure everything is added as a subview where needed. I've made sure I've tried everything I could think of short of setting the cell's X position in code. But since I'm not sure how to tell where the border is, I'd rather have the tableview or the cell do the work itself.
The question: How do I fix this? The selection accessory should be outside the grouping box. The text should be inside, not bleeding out onto the background like it is.I believe the content of the cell should be displayed inside the border within the yellow area.
The odd thing is, this is my fifth or sixth table in this app and I've been doing them all basically the same. Thus far this is the only one I've had trouble with.
Can anyone shed some light as to what's going on?
Thanks in advance
I think that to get this in code, you'd have to do something explicit, so the most likely candidate is a messed up IB file.
Since it doesn't cost anything, I'd just delete the tableView from the IB and then re-add it. If that doesn't work, try recreating the complete IB.
Hope that helps
I have a myriad of UIImageViews that act as 'tiles' on a map. They align up next to one another to form a grid of images.
Ordinarily, the grid images are flush against each other, but whenever the iPhone or iPad device is rotated, or if a UIView is applied to the view that contains these tiles, the spaces between the UIImageViews become momentarily visible, showing off the grid pattern that I'd like to be invisible.
Any ideas what might be causing this?
Thanks
Consider using CATiledLayer to draw all the images in a single view instead of using multiple subviews. There's a nice writeup on using it at Cocoa Is My Girlfriend. CATiledLayer makes it easy to build an image out of smaller tiles, display higher resolution images as the user zooms in, and avoid memory problems that come from keeping too much of a large image loaded.
this is happening because you are using different views (here uiimageview). Since they are not part of the same fabric during any animation or change in view hierarchy there is a chance that the gap between them would be visible.
This is a very common problem in graphics programming. The way to fix this problem is to have one single view and add these uiimageviews as sub-layers to this view. That way all the imageviews are part of the same fabric and the gap would not be visible.
I did not post any code but then so did you ;)