
Populating first item on iPad after reading objects from store
#1
Posted 07 April 2013 - 01:32 PM
Bruce
- hwf9vjkj8s2 likes this
#2
Posted 07 April 2013 - 10:41 PM
Try this:
[yourSection dispatchEventSelectRowAtIndexPath:yourIndexPath];
HTH
- Tarek likes this
#3
Posted 29 April 2013 - 08:15 AM
Hi Bruce,
Try this:[yourSection dispatchEventSelectRowAtIndexPath:yourIndexPath];
HTH
This doesn't work unfortunately.
Using a UISplitViewController, this ends up putting the detail view in the same pane as the master view.
#4
Posted 12 May 2013 - 11:01 AM
#5
Posted 15 May 2013 - 05:40 PM
Hi Bruce,
Is your master view controller connected to the detail view controller via masterViewController.tableViewModel.detailViewController = detailViewController ?
#6
Posted 19 May 2013 - 04:00 PM
Yes, it is.
I wonder if the issue is that when I am building the model I typically instantiate an SCArrayOfObjectsModel and then set self.tableViewModel to that.
Bruce
#7
Posted 29 May 2013 - 11:47 AM
Hi Bruce,
I can check the project for you if you wish. Please create a new support ticket and attach it there. Thanks.
#8
Posted 16 August 2013 - 01:54 AM
Tarek,
Anything on this? It's been almost a month now since I created the support ticket as you requested.
Bruce
#9
Posted 18 August 2013 - 05:51 AM
This happens to me too.
Please advise Tarek.
#10
Posted 06 September 2013 - 06:05 PM
#11
Posted 07 September 2013 - 12:22 AM
Greetings Programs!
I've been messing around with the sample iPad App trying to find some way to do it and I sort of have it displaying (but other things break)...
This isn't a solution or even remotely close to one but it could be a starting point for a workaround...
RootViewController.h
#import "DetailViewController.h" @interface RootViewController : SCTableViewController @property(nonatomic) BOOL isFirstLoad; @property(nonatomic, strong) DetailViewController *detailViewController; @end
RootViewController.m
// Create a weak instance of self to be used within the blocks. __weak typeof(self) weak_self = self; self.isFirstLoad = YES; self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController]; objectsSection.sectionActions.detailModelWillPresent = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath) { NSLog(@"detailModelWillPresent"); NSLog(@"detailModel: %@", detailModel); if (weak_self.isFirstLoad) { [[weak_self.detailViewController navigationController] popViewControllerAnimated:NO]; [[weak_self.detailViewController navigationController] pushViewController:detailModel.viewController animated:YES]; weak_self.isFirstLoad = NO; } else { weak_self.tableViewModel.detailViewController = detailModel.viewController; } }; [self.tableViewModel addSection:objectsSection]; if (self.isFirstLoad) { [objectsSection dispatchEventSelectRowAtIndexPath:(NSIndexPath *)[[self.tableView indexPathsForVisibleRows] objectAtIndex:0]]; }
Wg
P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)
#12
Posted 17 September 2013 - 02:32 PM
Hi Bruce,
I checked your app and it turns out that the DetailViewController didn't get the chance to load by the time MasterViewController appeared. This can be easily rectified by waiting by a really small interval (1/10 second is way more than enough) before dispatching the event. Here is a code sample that should work once added to your MasterViewController:
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self performSelector:@selector(selectFirstRow) withObject:nil afterDelay:0.1]; } - (void)selectFirstRow { SCArrayOfObjectsSection *objectsSection = (SCArrayOfObjectsSection *)[self.tableViewModel sectionAtIndex:0]; if(objectsSection.items.count) { NSIndexPath *firstRowIndexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableViewModel.tableView selectRowAtIndexPath:firstRowIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; [objectsSection dispatchEventSelectRowAtIndexPath:firstRowIndexPath]; } }
Please confirm that this is working.
Edited by Tarek, 17 September 2013 - 02:37 PM.
#13
Posted 17 September 2013 - 02:45 PM
Alternatively, you can also dispatch the event from DetailViewController itself (which might be an even better solution). Just place the following code in your DetailViewController:
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if(self.tableViewModel.masterModel) { SCArrayOfObjectsSection *objectsSection = (SCArrayOfObjectsSection *)[self.tableViewModel.masterModel sectionAtIndex:0]; if(objectsSection.items.count) { NSIndexPath *firstRowIndexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableViewModel.masterModel.tableView selectRowAtIndexPath:firstRowIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; [objectsSection dispatchEventSelectRowAtIndexPath:firstRowIndexPath]; } } }
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users