UA-17470720-3

Jump to content


Photo
- - - - -

What delegates for changing tableView backGround color?


  • Please log in to reply
24 replies to this topic

#1 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 18 September 2010 - 07:41 AM

I'm implementing the methods in the Core Data sample for iPad you sent, and all is working well, but some of my customizations are not working. Using delegate methods for cells (as noted in other posts works ok but for the life of me I cannot get the tableview background transparent. any changes to the tableView in IB are overridden it seems, and programmatic control is compiling but do nothing.

This is the steps so far: in my app delegate I create a background image and assign it as a subview of the window, thus:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {	
	
	UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];
	backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myAppBG.png"]];
	[window addSubview:backgroundView];
	[backgroundView release];
	//[window addSubview:self.navController.view];
	   [window makeKeyAndVisible];

		return YES;
}
Note that the navController is disabled; this is to confirm that the image is placed and sized as a backdrop properly. This works ok. Uncommenting the navController then lets the RootController do it's thing and overlays the backdrop. Now, the trick is to make the background of the section tableView transparent; I have tried variants of this code in the RootController's viewDidLoad:
// Init the tableViewModel
	tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
	self.tableView.backgroundColor = [UIColor clearColor];
	SCArrayOfObjectsSection *projectSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withEntityClassDefinition:projectDef];
	projectSection.addButtonItem = self.navigationItem.rightBarButtonItem;
	[tableViewModel addSection:projectSection];
Neither this code, variants, or tweaking the tableView in IB that is wired to the controller seems to work.

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 18 September 2010 - 11:38 AM

Have you unchecked the "Opaque" property in IB? Also, the following code should work:

self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;
self.tableView.backgroundView = nil;

BTW: any changes you do to your table view in Interface Builder are not overridden in any way, your table view will behave exactly as if you weren't using STV.

Hope this helps :)

#3 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 19 September 2010 - 05:18 AM

Yes! Now to get it into the delegate methods so the detail views match. Thanks!

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 20 September 2010 - 01:35 AM

You're welcome Geoffrey. Sorry I don't get your last comment, are you having any more issues or is everything working well now?

#5 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 20 September 2010 - 08:35 AM

Actually there are a few remaining head-scratchers, and a couple new ones popped up. For the most part delegate methods for configuring the cells are working great but there are hiccups in getting tableView and View customization to work on all the views that STV pushes on the navigation stack. In testing I can drop the code directly in the appropriate SC class implementations (for testing only of course :) )but when I drop back to implement code in delegate methods it seems a few methods aren't firing, or I'm not implementing them correctly.

Also having issues identical to the earlier problems Codebonbon had with the white BG appearing in the cell label when navigating back to the top of an array of objects, and having default grey add and edit buttons appear in a bar set to Black Navigation Bar. I have yet to try the RC you just sent this morning, and will see if that helps.

Finally, an issue with iPad autorotation; implementing the usual method to enable this and it works fine until the user clicks an add button; the resulting editable view STV pushes forced back to portrait and rotation is dead until reboot.

I am out of the office at the moment but will post later this afternoon with details.

#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 20 September 2010 - 09:02 AM

Hi Geoffrey,

1- This post provides some code samples on how to customize cells in detail views: http://www.sensiblec...erties.html#185 . You can also have full access to the detail view's SCTableViewModel by implementing the delegate method tableViewModel:detailViewWillAppearForRowAtIndexPath:withDetailTableViewModel: and accessing the "detailTableViewModel" property. Please tell me if you're still stuck with this.

2- Codebonbon issues have been resolved in the RC version you have, except the add/edit button on a black navigation bar issue which we are working on.

3- This auto rotation issue happens because the generated detail views do not implement the auto rotation methods. We're working on solving this too.

#7 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 20 September 2010 - 09:24 AM

Thanks, I'll be looking forward to trying it out. Yes, willConfigureCell and willDisplayCell are terrific methods for grabbing and customiszing cells; tableViewModel:detailViewWillAppearForRowAtIndexPath:withDetailTableViewModel: is the method that doesn't seem to fire but I'm sure it's something in my code; I'll look closer. Thanks again!

#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 20 September 2010 - 09:27 AM

Please make sure you're conforming to the SCTableViewModelDelegate protocol in your view controller's header file for the method to get fired.

#9 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 20 September 2010 - 02:46 PM

Yes I've got that configured correctly, the delegate fires and I can log it. the problem is that these properties I set in the viewDidLoad of the RootController...
self.tableView.backgroundColor = [UIColor clearColor];

	self.tableView.opaque = NO;

	self.tableView.backgroundView = nil;

	self.tableView.separatorStyle=1;
need to be applied to every view the application creates, even if they are automatically created for my by STV. I think the issue is with the syntax I'm using to access the properties in the delegate method; and an example would go a long way; thanks Tarek.

#10 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 21 September 2010 - 03:03 AM

Sure Geoffrey, here is a code sample:

- (void)tableViewModel:(SCTableViewModel *)tableViewModel
 detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath 
 withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
  UITableView *detailTableView = detailTableViewModel.modeledTableView;
  detailTableView.opaque = NO;
  detailTableView.backgroundView = nil;

  // Now if you want the above also applied to any of the sub detail views
  // of the detail views themselves, add the following line:
  detailTableViewModel.delegate = self;
}

Please tell me if this helps.

#11 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 21 September 2010 - 03:30 AM

Ah, I see what I needed to do, I'll try that. I was trying to do this:
detailTableViewModel.tableView.opaque = NO;
etc. and it was obviously not compiling.

I have noticed also, that maybe there is something wrong with the way I have my Core Data app handling the class definitions of my entities, in a way is keeping the willDisplayCell methods from both the SCTableViewCellDelegate and SCTableModelDelegate from being seen; I'll post the code later that is problematic (including the class definitions and such of the entities).

When I build the interface using simple and direct STV methods as in your samples and tutorials, configuration of cells is a no-brainer, but when I go the core data route I have a perfectly functioning app in minutes that can't seem to be customizable. I'm rather sure the problem is in my code and not yours :) .

#12 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 21 September 2010 - 05:02 AM

Core Data applications are as customizable as any other Senisble TableView application that has its cells and detail views automatically generated. In fact, they all live on top of the same identical framework.

For SCTableViewCellDelegate methods to get fired, you need to set the delegate of the automatically generated cells to your view controller. To do that, you simply set the uiElementDelegate property of your class definition to "self". For an example on how to do that, please refer to the following post: http://www.sensiblec...erties.html#185

#13 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 21 September 2010 - 02:06 PM

The code you gave me, applied this way ...
- (void)tableViewModel:(SCTableViewModel *) tableViewModel  
   detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath 
   withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{	
	UITableView *detailTableView = detailTableViewModel.modeledTableView;
	detailTableView.opaque = NO;
	detailTableView.backgroundView = nil;
	detailTableView.separatorStyle=1;
//
	detailTableViewModel.delegate = self;
}
works for everything except the view where an item is added, wherein it reverts to the vanilla default (this includes cell configurations added through willDisplayCell, which also work otherwise). Interesting that it's the Add (and Edit) buttons that bring up this view that aren't playing nice with the Black NavigationtionBar style as well.

Also, re cell configuration, I have this in my willDisplayCell method from SCTableModelDelegate:
- (void)tableViewModel:(SCTableViewModel *) tableViewModel 
 willDisplayCell:(SCTableViewCell *) cell 
 forRowAtIndexPath:(NSIndexPath *) indexPath	

if([cell isKindOfClass:[SCDateCell class]])
	{
		SCDateCell *dateCell = (SCDateCell *)cell;
		dateCell.datePicker.datePickerMode = UIDatePickerModeDate;
		NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
		[dateFormat setDateFormat:@"EEEE MMMM d, YYYY"];
		dateCell.dateFormatter = dateFormat;
		[dateFormat release];
	}
And this works except the dateFormat is not applied to the cell until it has been 'picked' against the custom datePickerMode.

#14 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 21 September 2010 - 04:04 PM

detailViewWillAppearForRowAtIndexPath does not get called when a new item is added (since the cell hasn't been created yet!), you should use the tableViewModel:detailViewWillAppearForSectionAtIndex:withDetailTableViewModel: method instead (with the exact same code).

As for the black navigation bar issues, these are being solved now and should be working well in our new release.

Finally, I don't get your last datePicker question, would you please elaborate on that? Thanks!

#15 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 21 September 2010 - 05:09 PM

Super, thanks! I'm learning how powerful delegation is in STV but there is a learning curve. Looking forward to the nav bar solution as well as the rotation issue and having modal views appear in configurable sheets and popovers. Important to iPad devs.

The datePicker formatter is a different issue and I may know what's happening there, let me try a couple of things and post on it later.

#16 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 21 September 2010 - 05:23 PM

I'll send you now a pre-release version that has the rotation and iPad modal sheets issues solved. Please tell me if it's working well for you, thanks!

#17 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 21 September 2010 - 06:46 PM

I made sure to completely delete the 1.5.9 RC3, cleaned all builds, and recompiled, but there is [strike]no change yet in any issue[/strike] SEE UPDATE. With the proper delegate method I can now style the tableView background in the 'add' view as per the previous post, but the menu bar is still default grey in the add view. The add button and edit button is default grey on the black navbar on the preceeding view (except on the top-level view;the sub-views affected are 2 sub-arrays of entities). [strike]The add view still kills rotation[/strike], and the modal version of the picker behaves modally as before but is still a full screen and not a sheet/overlay. If needed I can send along my project to your support email and you might have a look to see what is at issue.

UPDATE: on the last build a minute or two after the first edit the rotation issue seems fixed. NavBar and modal sheet issues still unchanged.

#18 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 22 September 2010 - 01:11 AM

Yes please send in your project to our support email, that would be really helpful. BTW, your black nav bar issues are still to be fixed in our next release :) We could give you another pre-release in a few days though. Thanks a lot Geoffrey.

#19 Geoffrey Alexander

Geoffrey Alexander

    Sr. Member

  • STV 2.0
  • PipPipPip
  • 42 posts
Reputation: 0
Neutral

Posted 22 September 2010 - 06:19 AM

I'll do that; let me do some more tweaking and let me copiously comment-up the code I have (the project file you'll receive represents about a third of the app as envisioned but STV has already put us way ahead on our timetable) and I'll mail to the address you sent the last code from, unless you have another. I'll certainly look forward to the latest code you can send me, always -- the fewer glitches I have to explain to our investors the better :) .

#20 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 September 2010 - 10:36 AM

Thanks for sending your project Geoffrey. I've sent you back the project with an updated version of STV that should solve all your issues. Please tell me if everything is working well for you now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users