Welcome, Guest
Username Password: Remember me

Dynamic Content for SCTableViewModel
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Dynamic Content for SCTableViewModel

Dynamic Content for SCTableViewModel 1 year, 7 months ago #1

Hi,

I'm trying to use the SCTableViewModel in a dynamic context. I have a navigation controller set up which uses SCTableViewModel. There are some cells which pushes a new viewcontroller to the navigation stack. In this controller there is an add button, which adds a new object to the model and pops the new viewcontroller and goes back to the root. When this change occurs I need add a new cell to show that a new object is added.

Let me give you an example of what I'm trying to do.

The root view controller is "My profile" and I have my information entered in this view. This page also contains my cars in different cells. There is a cell which says "Add a new car". When I add the new car in the new controller, it goes back to "My Profile". If I leave it to that, I can see that I have added the new car. What I need to do is change "My Profile" table and show the new content also. My code basically looks like:

 
- (void) viewDidLoad {
[super viewDidLoad];
 
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
 
[self constructSection1];
[self constructSection2];
}
 
- (void) constructSection1;
- (void) constructSection2;
 


What I tried doing is like:

 
- (void) viewDidLoad {
[super viewDidLoad];
 
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
}
 
- (void) viewWillAppear {
tableViewModel = nil;
 
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
 
[self constructSection1];
[self constructSection2];
}
 
- (void) constructSection1;
- (void) constructSection2;
 


I also tried:

 
- (void) viewDidLoad {
[super viewDidLoad];
 
tableViewModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
}
 
- (void) viewWillAppear {
[tableViewModel clear];
 
[self constructSection1];
[self constructSection2];
}
 
- (void) constructSection1;
- (void) constructSection2;
 


I also tried the method removeAllSections instead of clear.


None of these code works as intended. The first solution seems to work, but the autoscroll for the keyboard doesn't work anymore and I think it's not a good programming approach. I don't know what to do and this is one of the most crucial things in my project. I hope you can help.

Thanks,

Oguz
  • leweo
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0

Re: Dynamic Content for SCTableViewModel 1 year, 7 months ago #2

Not sure what type of SCtableViewSections you're using but try [tableView reloadData]. The table should refresh drawing from the updated data source.
  • panamind
  • OFFLINE
  • Senior Boarder
  • Posts: 77
  • Karma: 4

Re: Dynamic Content for SCTableViewModel 1 year, 7 months ago #3

I don't have a data source, I manually construct the cells in the section. The section is a default SCTableViewSection.

One more quick question, can we use the Sensible TableView for 3.0 devices?
  • leweo
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0

Re: Dynamic Content for SCTableViewModel 1 year, 7 months ago #4

Thanks Gary for helping out

Why are you doing all this manually Oguz? You can just use an SCArrayOfObjectsSection in your root view controller, set it up using a car class definition, and have it manage all the detail views and cell additions automatically for you. This is what we used to add tasks in our sample applications provided with your STV copy.

Regarding 3.0 devices: Our new 1.6 version is due for release very late today, and will fully support developing for 3.0 devices.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Dynamic Content for SCTableViewModel 1 year, 7 months ago #5

Thanks to both of you.

Reloading the tableview didn't work at first then I changed some codes in multiple places and tried it again. Now it seems to work.

Thanks a lot.

P.S: I didn't want to use the SCArrayOfObjectsSection, because what I was trying to do didn't seem to fit into any of the classes Sensible Cocoa provided, but still I managed to do it finally =) thanks..
  • leweo
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
  • Page:
  • 1
Time to create page: 0.99 seconds