Yet more new information. Was: Re: Weird UITableView problem
Yet more new information. Was: Re: Weird UITableView problem
- Subject: Yet more new information. Was: Re: Weird UITableView problem
- From: William Squires <email@hidden>
- Date: Thu, 30 Apr 2015 09:44:36 -0500
Okay, I've now tried this on Xcode 5 and 6, and on 10.8.5 and 10.10.3. Here's my synopsis:
* Happens only with UITableView
* Happens on simulator if set for any device (except iPad?) that has retina display
* Does not happen if set for a non-retina device.
* Unknown if this happens on real devices (retina or not).
* Happens regardless of the scale factor of the simulator display if the Mac does not have a retina display. Unkonwn what happens if your Mac does have a retina display (I don't have one.)
* Happens with Swift or ObjC project
* If set for iPad Air, all the rows are "available", plus about 3 to 4 blank ones - this happens regardless of the scale factor (by "available", meaning you can see them, or scroll down to see them.) If the scale factor is set to see all the simulator screen, then the (simulated) UITableView has no scroller and you can see all 20 of the rows, plus 3 blank ones (the rows are there, but have no cell.textLabel.text)
This is a fairly easy project to duplicate. Just create a "Single View" iOS project with target iOS 7+, for Universal, and either ObjC or Swift. Add a UITableView to the main view, set your view controller to implement UITableViewDelegate and UITableViewDataSource. Connect the outlets to the view controller in IB. Set up some "content" (an array of 20 or so items), and feed it to the UITableView via tableView:numberOfRowsInSection: and tableView:cellForRowAtIndexPath: then set your target device to iPad air, and then again to some iPhone (say, 5s, or 6) that has a retina display.
If possible, I'd like someone to try this on an actual iPhone, as well as to try it on the simulator on an iMac that does have a retina display.
On Apr 28, 2015, at 11:45 AM, William Squires <email@hidden> wrote:
> Thinking this was a Swift problem, I recreated the project, but with ObjC as the language. I set up the UI the same as with the Swift project. It too, only shows a subset of the array, only this one shows 15 rows, not 13. Here's the ViewController.m
>
> //
> // ViewController.m
> // SimpleObjCTable
> //
> // Created by William Squires on 4/28/15.
> // Copyright (c) 2015 William Squires. All rights reserved.
> //
>
> #import "ViewController.h"
>
> @interface ViewController ()
>
> @property NSArray *dwarves;
>
> @end
>
> @implementation ViewController
>
> - (void)viewDidLoad
> {
> [super viewDidLoad];
> self.dwarves = [NSArray arrayWithObjects:@"Sleepy",
> @"Sneezy",
> @"Bashful",
> @"Happy",
> @"Doc",
> @"Grumpy",
> @"Dopey",
> @"Thorin",
> @"Dorin",
> @"Nori",
> @"Ori",
> @"Balin",
> @"Dwalin",
> @"Fili",
> @"Kili",
> @"Oin", // These are not shown.
> @"Gloin",
> @"Bifur",
> @"Bofur",
> @"Bombur",
> nil];
>
> // Do any additional setup after loading the view, typically from a nib.
> }
>
> - (void)didReceiveMemoryWarning
> {
> [super didReceiveMemoryWarning];
>
> // Dispose of any resources that can be recreated.
> }
>
> #pragma mark "UITableView Methods"
>
> -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
> {
> NSInteger theCount = [self.dwarves count];
>
> NSLog(@"theCount = %ld", theCount);
> return theCount;
> }
>
> -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
> {
> NSLog(@"indexPath.row = %ld", indexPath.row);
> UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
> if (cell == nil)
> {
> cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SimpleTableIdentifier"];
> }
> cell.textLabel.text = [self.dwarves objectAtIndex:indexPath.row];
> return cell;
> }
>
> @end
>
> running it gives me (in the debug console) 4 instances of "theCount = 20", followed by 15 lines of "indexPath.row = 0" up to "indexPath.row = 14" (15 total, which corresponds to the comment in the initialization line for dwarves = NSArray... line above.) In both cases (the Swift project, and the ObjC project) I use the default view (with the size class w:any, h:any) and pin the UITableView to the edges of the parent view.
> Now I'm totally lost as to why only a limited subset of the rows are being shown, especially given that tableView:numberOfRowsInSection: consistently returns 20 (the number of items initializing the array). HELP!!
>
> On Apr 26, 2015, at 11:29 AM, William Squires <email@hidden> wrote:
>
[snip]
_______________________________________________
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