Empty UITableView scrolls slowly on iPhone 4 running ios 7 - ios

Ok, I'm at a loss. I have a tableview that works fine in iPhone 5/5S, but can only manage 4 fps on an iPhone 4. I've tried every trick in the book to optimize the cells (opaque, misaligned frames, no blending, render uilabels into images, static cell heights, etc), but it didn't even move the needle. Thinking that the root cause could be somewhere else, I decided to strip out all my custom cell code so that cellForRowAtIndexPath: returns an empty (but re-used) UITableViewCell, and even that runs slow... I've tried profiling the app while scrolling the tableview, but nothing stands out at all. The only thing that seems suspicious is that if turn on CoreAnimation's Color Hits Green and Misses Red, the status bar will constantly flash between green and red as I scroll the tableview. This leads me to believe that the status bar is being redrawn every frame (or every couple of frames), but even hiding the status bar didn't improve the fps by much (maybe 4 -> 7).
So.... I'm at a loss. Anyone out there experience something like this and can point me in the right direction?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:__inboxCell];
if (! cell)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:__inboxCell];
return cell;
}
Here's when I run a time profiler and get around 6 fps:
When I remove the system libraries, it's pretty useless. If I keep scrolling for a few minutes, the % of Parent for cellForRowAtIndexPath: will greatly exceed that of didFinishLaunchingWithOptions: (which obviously only runs once).

Related

TableView Cells Overlapping UIView After Scrolling Down and Up

I'm playing around with some design concepts and I got stuck with this "bug."
Any idea why is this happening? I've iterated through different things and still can't find the culprit or solution to this.
This "circle" for the price, overlapping the other cell at the bottom of it is my intended design. This is all good, however, when I scroll down and back up, "older" cells suddenly overlaps the "circle."
Kindly see the screenshot. Any help is much appreciated!!!
Has anyone experienced this before?
iOS9 - Xcode 7.3.1
EDIT:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCellWithIdentifier("CategoryCell") as? CategoryCell {
cell.selectionStyle = .None
cell.configureCell(dishes[indexPath.row])
return cell
} else {
return UITableViewCell()
}
}
EDIT 2:
After further analysis, I am quite convinced that this has nothing to do with the height? I played around using different heights but still get the same results.
The thing is, it loads perfectly, even when scrolling down, it's all good. Up until I scroll back up, that's where the problem starts to appear.
Setting the Clip SubViews (Cell) to true will clip everything even on load, so I've set it to false.
The remaining question is, how to handle the clipping when scrolling back up?
EDIT 3:
I think I now understand the problem however, I am still not quite sure how to solve it.
The CircleView is placed on a cell that is meant to overlap to the other cell below it. Settings clipsToBounds, height or putting it infront will have no effect to the cell below it as it goes away from the display when scrolled up.
Anybody has an idea how to somehow redraw this just like it has been freshly loaded (because onload, things are working)? or perhaps is there a clipsToBounds setting elsewhere that I am missing?
I think the solution relates to this: How to stop UITableView from clipping UITableViewCell contents in iOS 7
However, this solution is not working on ios9.
Set the cell layer anchorPointZ to row index in cellForRowAtIndexPath: method
cell.layer.anchorPointZ = indexPath.row;
The issue has to do with the height of your cell. It isn't going to dynamically adjust that for you.
You can try setting the clips to bounds on the tableView (check screenshot)
clipsToBounds option
Have you tried setting an estimatedRowHeight for the tableView? Also, you can use the function heightForRowAtIndexPath and return UITableViewAutomaticDimension. That should automatically dimension every row to fill the circle size.
EDIT: If you want to bring the circle to the front of everything else, try this:
YourLabel.layer.zPosition = 1;
self.view.bringSubviewToFront(YourLabel);

iPhone 6 Plus show strange lines in UITableViewCell next to the accessoryView

I have a UITableView that is showing some strange thin grey lines next to the accessory view. This ONLY happens on the plus, no other iPhone shows this issue.
It seems to have something to do with the imageView that is assigned to the cell. Some images cause the line, others don't, seemingly based on their dimensions.
Has anyone else seen this or know how to get rid of it?
I experienced this when using a UITableView that was partially covered with an SWRevealViewController.
When the calculated value of the tableview width was a decimal number, artifact lines between the content of a UITableViewCell and the accessory view would appear.
The solution was to make sure that size calculations for the view were rounded to whole numbers.
It looks like that line is from the right edge of the cell's content view. I don't know how it works, but my solution was:
cell.backgroundColor = .clear

Can UITableView's scroll 'smoothly' when using various height Self Sizing Cells?

I have a UITableView with Custom UITableViewCell's. The Cell's can vary between 200.0 and 300.0 and height.
Now if you open Facebook, you'll notice the scrolling in the News Feed is awfully choppy. However, this is likely due to that various videos that are loaded on every cell, and that the time taken in cellForRowAtIndexPath is greater than 13.67ms (1s/60frames). Hence the choppy 'flicker'.
Quora on the other hand has cells that are varying heights, between probably 150.0 and 400.0+. It scrolls pretty smoothly however.
Now, when I scroll my tableView it's as though my screen is 'jumping'. I will scroll down, and every now and then (may every new cell dequeue but not quite), it's as if something higher up in the tableview got a few pixels shorter in height, and therefore the screen i'm currently viewing jumped up a few pixels. (This is not what's happening, I'm just trying to paint a picture of what it looks like).
Now I know it's not a time related issue. My cellForRowAtIndexMethod is nowhere near 13.67ms. It's always around 3ms, so that's not the issue.
2 questions...
1) Is this typically indicative of an auto layout issue?
2) Is there an accurate/semi-accurate way to calculate estiamtedRowHeight when you have such varied cell heights, or would having an accurate number here not fix this issue anyway? Just an idea.

UITableViewCell resizing automatically when presented

I have a strange problem.
When my UITableView is presented, for a brief second, the cells change their height(not much but its noticeable and i do not like it). And it only changes when the device is running IOS 8. I tried it on my device using IOS 7 and nothing happened. Anyone knows what this can be?
There may be a discrepancy between the UITableViewCell height in your xib/storyboard and the height you're specifying in the delegate method heightForRowAtIndexPath.
Edit:
If that isn't your issue, try calling that delegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60;
}
or:
Specifying a height that is not 'default' since the resizing probably has something to do with the scaling of device size.

iOS: Tableview with custom cells does not scroll

I'm using a nav bar orchestrated set of tableviewcontrollers to display a hierarchy of data. The bottom level of data is displayed in a custom tableviewcell, which has its content described in a xib, and results in a required cell height larger than the default. I posted another question on how to programmatically extract the resulting cell height, but no usable answers, so I now implement heightForRowAtIndexpath to return a hardcoded value that is the height in the xib attributes panel. But, when the table is displayed with more rows than can fit in the normal display size (480h,320w), the bottom row is chopped off as expected, but I can't scroll it to see the rest of the row. I've searched rather extensively, but nothing has helped. I poked at various attributes (tableview sizes, scrollingEnabled, etc.) but they all seem as expected values (e.g., scrollingEnabled is true). One post suggested that no scrolling would occur unless the contentSize was larger then the frame, so I looked at those values, and it sounds promising, in that my frame size is a typical 460h x 320w, but, my contentSize is 0 x 0! Further searching (e.g., "setting contentSize" or "contentSize is 0") didn't clear anything up. I thought contentSize was computed for free from the table row count and their heights, so how could I be getting 0? Even going back to allowing a default row height by not implementing heightForRowAtIndexpath still resulted in a 0 contentSize. Some searches suggest turning off autoLayout for the custom table cell, but still the same. So, what might be going awry? Thanks for any thoughts or guidance.
Update: Sorry, I confess! I had originally been developing on a mac mini with a regular USB mouse, where scrolling in the simulator was left button down and drag. I recently switched to an iMac with the magic mouse. I'm now so used to just dragging my finger on the mouse to scroll code, web pages, etc., that I didn't think to try clicking and holding the left mouse "button", and then dragging the mouse. When I did, everything worked as expected. I had really thought things were hopeless when any similar variables/values in the app on the mini were equal to those on the iMac, but it was just me getting tricked by fancy technology. Sorry for the distraction.
set your tableView's frame and your cell's frame correct,and implement
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath in your UITableView to give a right height. If that doesn't work try set your tableView.autoresizingMask to UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
which can help you with the size of the tableview
I had a similar problem. My tableView would't scroll when the content exceeded the tableViews frame.
The problem for me was that I had "Use Autolayout" checked but no constrains on the tableView. Adding vertical and horizontal space constrains on the tableView fixed my problem

Resources