UA-17470720-3

Jump to content


Photo
- - - - -

Mix own (old) TableView-Code to STV


  • Please log in to reply
11 replies to this topic

#1 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 03 January 2014 - 03:44 AM

Is it possible to add a section provided by STV Code to an already existing TableView (with my own table view methods)? I can provide the correct values for sections in table and number of cells in section, but how can i retrieve the cells of the STV-Section to give them back in my cellForRowAtIndexPath?



#2 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 03 January 2014 - 09:30 PM

to add extra sections to a STV table

SCTableViewSection *section = [SCTableViewSection section];
section addCell:[SCTableViewCell cellWithText:@"Row1"];
[self.tableViewModel addSection:section];

to get values back you could use

[self.tableViewModel cellAtIndexPath:indexPath];

 

is this what you talking about?


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#3 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 12 January 2014 - 09:34 AM

to add extra sections to a STV table

SCTableViewSection *section = [SCTableViewSection section];
section addCell:[SCTableViewCell cellWithText:@"Row1"];
[self.tableViewModel addSection:section];

to get values back you could use

[self.tableViewModel cellAtIndexPath:indexPath];

 

is this what you talking about?

 

No, the TableView i want to add cells from STVTableView to is not a SCtableViewController. Even if i would subclass it from SCTableViewController, i do not want just to add a new SCTableViewSection to it, but i want to get selected cells from the SCTableViewSection. I would need something like creating an SCTableViewController in the background and use its cells with the cellAtIndexPath. How could i achieve this, without actually bringing this background table to view (so viewDidLoad will not be called for it)?



#4 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 12 January 2014 - 02:06 PM

Ok, now i found out how to get and display the cell from SCTableViewController (constructed in background), and everything looks ok. But how can i send the didSelectRowAtIndexPath i receive for my tableview to/for the corresponding cells in the SCTableViewModel? 



#5 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 12 January 2014 - 02:35 PM

Sorry, you not making sense to me.. do u have two tableview on the view or something?? help me out here.. even with some code.. maybe we can see what your trying to do and help make it easier

 

anyways.. to select a cell in code

SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection........
    
[objectsSection dispatchEventSelectRowAtIndexPath:<indexpath>];

Edited by ozie, 12 January 2014 - 03:08 PM.

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#6 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 13 January 2014 - 11:26 AM

Sorry, you not making sense to me.. do u have two tableview on the view or something?? help me out here.. even with some code.. maybe we can see what your trying to do and help make it easier

 

anyways.. to select a cell in code

SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection........
    
[objectsSection dispatchEventSelectRowAtIndexPath:<indexpath>];

 

Please read again my original posting for a better understanding. I have an existing good working and quite complex tableview that does not make use of STV. I don't want to create this all new from the scratch with STV, mosty because STV does not offer all cell types that i already use and is quite weak with custom cells (there is an open question in another thread on this from me). What i asked is if it is possible to use single cells from an new small STVTableView that i can integrate into my big existing TableView (on a per cell basis). With your help i was able to do so, but only half way. When i tap on the STV-Generated Cells iOS (of course) calls my already existing didSelectRowAtIndexPath, which i want to promote to the STV Generated Cell to start STVs cell editing code work. How can i achieve this?



#7 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 13 January 2014 - 08:30 PM

Being that STV builds on the normal tableview it might be possible but i have never tried mixing old code with new

 

 because STV does not offer all cell types that i already use and is quite weak with custom cells

weak?? i have not found any problem with custom cells as you make them, and they do what you want them to.. The OTB custom cells that come with STV are standard basic cells that most need and use in any app, and anything thats not there you just make yourself. Taking a guess that you are new to STV, there is a little learning curve but anything you could build before you can still build in STV. Have a read through the forums and the eBook about SCCustomCells 

 

as for why things are not calling the STV methods but instead calling the standard methods, my guess would be because your not connecting a SCTableModel to the tableview and connecting things up the way they weren't meant to be used. If it is possible your going to have to play around or talk to Tarek about that


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#8 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 14 January 2014 - 01:17 PM

I asked tarek about this, but he simply did not reply. As for the custom cells, it does not work to create one with more than one attribute in it coming from the database and make STV edit exactly one of the fields when the user taps on the cell. See my other open question on this topic which is still unanswered. It is not possible to create a cell with name, value and unit with STV as a custom cell, so i just wanted to use STV for the easy cell types. But this does not work in mix right now, because i can not propagate the didSelectRowAtIndexPath calls to STV. Using STV makes more work than it saves me up to now. And yes, of course i read through the documentation and the book. The generic STV cells look quite "ugly" and when you start modifying things they do not work anymore. The examples in the book are too simple to work in a real life project.



#9 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 14 January 2014 - 02:17 PM

again i will answer, "you can do anything with STV that you can do normally". You can make a custom cell that can display as many attributes as you want, not just one.

If you want it to edit just one field then you can make it do that too.

 

As for referring all the time to the other question, maybe you need to re-phrase it to make it make more sense so that others can fully understand what you are asking to be able to help

 

I can tell that its frustrating you, but it was not designed to be used as a sub filler to build half into existing table code. You asked why the cell you did get to add to the existing table still calls the existing tableview did select cell code, that would be because that is what a tableview does when the delegate is set. You currently will have to use the section object you created to add the cell to call its own cellAction.didSelect and then in the tableview delegates did select code test what type of cell class is there, and when its the new cell type not use the code

 

You shouldn't be trying to modify the normal STV cells, you should be creating your own cells from scratch. yeah the samples are simple, the book would be too big to try and explain everything and anything.


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#10 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 15 January 2014 - 12:35 PM

Here is the link to my other question about the cell displaying two attributes, of which one should be edited when the user taps on the cell:

 

http://sensiblecocoa...s-not-editable/

 

I know, why my didSelectRowAtIndexPath is called. The question is, how can i promote this to the STV generated cell (if this is possible at all). The hint to "didSelect" may help, i will try to find this method in the documentation.



#11 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 15 January 2014 - 10:21 PM

i had a quick read over your other question.. the question kinda makes some sense but not fully as to what your trying to do, and the code sample is not good enough to really see.

the code shown is what is used for when in the detail view is loaded to edit an object...

and since I'm guessing here that you are not viewing the cell in the detail view, but rather in the basic loaded tableview displaying items, the cell is not in edit mode, which is why it displays grey, as its being selected.. this the the normal behaviour of a tableview.. if the cell is in edit mode, then when tapped the values are editable, else its just a cell that is like a big button

 

Since you question is all messed up trying to mix code to half fill some void in code its making less sense and seems like too much work

i would suggest either converting the view into STV, or just continuing on with the old coding way and only using STV in any new views you create and use.. i think you will drive yourself mad otherwise


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#12 notreallyme

notreallyme

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 82 posts
Reputation: 8
Good

Posted 09 February 2014 - 10:41 AM

i had a quick read over your other question.. the question kinda makes some sense but not fully as to what your trying to do, and the code sample is not good enough to really see.

the code shown is what is used for when in the detail view is loaded to edit an object...

and since I'm guessing here that you are not viewing the cell in the detail view, but rather in the basic loaded tableview displaying items, the cell is not in edit mode, which is why it displays grey, as its being selected.. this the the normal behaviour of a tableview.. if the cell is in edit mode, then when tapped the values are editable, else its just a cell that is like a big button

 

Since you question is all messed up trying to mix code to half fill some void in code its making less sense and seems like too much work

i would suggest either converting the view into STV, or just continuing on with the old coding way and only using STV in any new views you create and use.. i think you will drive yourself mad otherwise

 

Please provide answers/questions about the custom cell containing two attributes at the other thread. What i need to do is quite simple: I have a custom cell with two attributes from the database. One of them ("limit") should be edited when the user taps on the cell, the other ("unit") should not be edited when the user taps on the cell. How can i get STV to do this?

 

One additional question arises here when using the automatic collection type (SCPropertyTypeArrayOfObjects) of STV. In the list view where the user can add entities it seems that STV simply sets the value of the topmost column of the object to represent the cell. I use this for letting the user set alarms where he can configure a category, a limit, an phone-number that should be observed and some other attributes. So when the user adds two alarms with the same category (but for different numbers or/and different values) both of them appear in the list view with the same name (because the category is the same). What i need here is a way to tell STV what combination of values should be presented in the collection main screen so the user can distinguish what he has entered without the need to look into each entry. Is there a way to do so, or is STV not suitable for this kind of real world application?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users