Mr_CryptoPrime
Mr_CryptoPrime

Reputation: 638

Strange Lines on UITableView?

enter image description here

The background of UITableView is set to green and the color of UITableViewCell is purple and the separators is in black color. I can't figure out where these white lines are coming from? When I scroll up the separators glitch on and off and the white lines stay as it is (where they are). Since I have no idea what's causing this, don't know which code to post save the whole lot of it...Is this from bad code or the simulator being buggy? Scaling up and down doesn't do anything and changing the separators and table footer is moot. If you could help point me in the right direction I would be eternally thankful!

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier( NSStringFromClass(GameTableViewCell), forIndexPath: indexPath) as! GameTableViewCell
    cell.game = gameList[indexPath.row]
    cell.selectionStyle = .None
    print("Row = \(indexPath.row)")
    return cell

}

Upvotes: 0

Views: 966

Answers (4)

sonle
sonle

Reputation: 8866

This weird behavior still happens on iOS 16. There is a strange line at the bottom of TableView. Even though I've set separatorStyle = .none and viewForFooterInSection to nil.

enter image description here

Solution: After a few hours of UI debugging and researching, I've found this work around. Then the line disappeared, seems like it was a UIKit bug.

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    UIView()
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    0.1
}

Upvotes: 0

designer
designer

Reputation: 45

In my case, I copied and pasted a scrollview from another project into my current project and THEN copied and pasted a UITableView into that scrollview from another controller (that was NOT showing separator lines properly). I could not get ride of those separator lines regardless of code... because of this copy / paste...

My solution was to simply create a new scrollview and then copy / paste my UITableView into the newly created scrollview.

I'm no expert, but copy and paste did not work for me when placing the UITableView inside a copy and pasted scrollview...

Starting with a fresh scrollview worked. Got rid of those separator lines... took about 2 minutes to fix...

Upvotes: 0

Tarun Seera
Tarun Seera

Reputation: 4402

Try with high resolution simulator and check is it still appearing, some times its Simulator bug

Select Simulator and press Command+1 and now check

Upvotes: -1

Vinod Vishwanath
Vinod Vishwanath

Reputation: 5891

To figure out issues like this, always use the UI debugger. Run the project with a simulator/device, and in Xcode's bottom panel, choose the button highlighted below:

enter image description here

The debugger will allow you to visually inspect all the layers of your UI and where each UI element is coming from (along with memory addresses, sizes etc.)

Below is an example where I have dragged to rotate and inspect the Z-indexes of the view:

enter image description here

Hope this helps.

Upvotes: 4

Related Questions