• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Weird UITableView problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird UITableView problem


  • Subject: Weird UITableView problem
  • From: William Squires <email@hidden>
  • Date: Sun, 26 Apr 2015 11:29:47 -0500

I made a fairly simple iOS app (Single View template, iPhone, Swift) that has a UITableView. I've got it all hooked up, and running the project (in the simulator) shows the table view, but only 13 (out of 20) rows are ever shown.

here's the deal:

ViewController.swift
--------------------
class ViewController: UIViewController, UITableViewDelegate, UITableViewSource
{
private let dwarves = ["Sleepy",
                       "Sneezy",
                       "Bashful",
                       "Happy,"
                       "Doc",
                       "Grumpy",
                       "Dopey",
                       "Thorin",
                       "Dorin",
                       "Nori",
                       "Ori",
                       "Balin",
                       "Dwalin",
                       "Fili",  // From here on, these might as well not exist (index >= 13)
                       "Kili",
                       "Oin",
                       "Gloin",
                       "Bifur",
                       "Bofur",
                       "Bombur"
                       ]
let simpleTableIdentifier = "SimpleTableIdentifier"

...

// MARK: UITableViewDataSource/UITableViewDelegate methods
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
  {
  return dwarves.count
  }

  func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
  {
  var cell = tableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier) as? UITableViewCell
  if (cell == nil)
    {
    cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: simpleTableIdentifier)
    {
  cell!.textLabel?.text = dwarves[indexPath.row]
  return cell
  }
}

When run, only the first 13 names are shown in the table view; everything from "Fili" on does not show up. I would expect either:

1) a syntax error in the array declaration (which should be caught by Xcode)
2) show all the items in the array, or
3) show none of them.

Is there a (hidden) limit in the simulator that only 13 rows can be shown in a UITableView? If not, can anyone else replicate this problem?

Finally, how do I call NSLog() from Swift, and have it print an object? In ObjC, it would be:

NSLog(@"My object: %@\n\n",myObject);

where myObject resides in MyObject.m and declared in MyObject.h and implements -(NSString *)description – in Swift, I would just have a .swift file, but how would I print it (myObject variable) to the (debug) console at runtime? What about a Swift "String" type?



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • New information. Was: Re: Weird UITableView problem
      • From: William Squires <email@hidden>
    • Re: Weird UITableView problem
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: One must handle UIInterfaceOrientationUnknown
  • Next by Date: Re: Weird UITableView problem
  • Previous by thread: One must handle UIInterfaceOrientationUnknown
  • Next by thread: Re: Weird UITableView problem
  • Index(es):
    • Date
    • Thread