I have a custom cell table view showing arrays with 4 different infos, on 4 labels.
On another view controller I have a UISwitch, which if switched off, should lead to one of the labels to not show anything.
I was thinking to create a boolean, but this does not get picked up in the tableview.
Any help would be greatly appreciated.
Thanks.
You can set the label conditionally in cellForRowAtIndexPath and just call reloadData on the tableView when you hit the switch.
Related
I have created three prototype cells in a split view master view controller, each will hold an NSArray. I also gave each cell a unique identifier.
I need for the cell, when pressed by user to go to its own individual view controller. Please tell me how to code/format the cellForRowAtIndexPath part. I have read many posts saying---now you just need to change the cell for row part--making it sound like something really simple---but code example not given and I just don't see it.
Please Help--been trying to figure this out for hours now!
Thanks!
If you are using storyboards you can do it in the storyboard because you are using prototype cells. You can just make a new push to the view controller for example for each of your three cells. I beleive that the cellForRowAtIndexPath is more for dynamic cells.
Relating to UITableView sections to always stay within view but I got an idea I'm not sure of:
Has anyone ever tried to nest a UITableView in another UITableView, whether by putting the second one as the tableHeaderView or as a section header of the first one?
UITableView is derived from UIScrollView. It is generally not a good idea to have a scroll view inside a scroll view (exception: when the scrolling directions are perpendicular to each other).
Otherwise you would end up with a user interface that is not appropriate for most users.
I am trying to make a drill down table with storyboards in a Tab bar app.
I am having a problem with working out how to get each row in a main table to point to other different tables.
This is the code I have used to detect row selection.
-(void)tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *__strong)indexPath {
TableViewController *table = [self.storyboard instantiateViewControllerWithIdentifier:#"table"];
[self.navigationController pushViewController:table animated:YES];
}
How do I proceed please?
The real beauty to UIStoryBoards are the segues.
1. You can link one prototype cell push segue to another different table view controller
2. You can link one prototype cell push segue loop back to itself for drill downs.
[self performSegueWithIdentifier:#"segueID" sender:MyObject];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([segue.identifier isEqualToString:#"segueID"]) segue.destinationViewController.chosenCell = sender;
}
If the segue is from the cell click, the sender is that of the cell and you can get it's indexpath from the table, and pass new information to the upcoming view controller.
If you want the cell to take various paths when clicked, keep the didSelectRowAtIndexPath and call performSegueWithIndetifier so you can choose left or right.
Tutorial: http://jleeiii.blogspot.com/2012/05/uistoryboard-power-drill-batteries.html
GitHub: http://www.github.com/jllust/UIStoryboardExamples
I was extremely frustrated with this, as the storyboards with tableviews is really not covered ANYWHERE. I literally almost pulled my hair out trying to figure this out. So my frustration is your luck!
Comparing your code to mine, yours looks fine other than the fact that in the initial didSelectRowAtIndexPath: method, you have *_strong, which should not have the _strong part. It should just be like this: (NSIndexPath *)indexPath {
Additionally, be careful in when you are referring to the instantiateViewControllerWithIdentifier in Interface Builder. I accidentally filled out the name of the instance variable under 'TITLE' instead of 'IDENTIFIER'
I hope this helps. I completely understand your frustration.
In your storyboard, if the content is Static Cells, you can ctrl-drag from the specific row to a Navigation Controller. Then connect the Navigation Controller to your next table. Look at this screen shot. http://cl.ly/1V2y0v202y390U0A351x
My guess is that progromatically, you'll need to do something similar, segue to a NavigationController which has a table view controller as it's root view.
I'm just learning and playing with the apple Seismic XML example
http://developer.apple.com/library/ios/#samplecode/SeismicXML/Introduction/Intro.html
I've got most of it figured out, but the one area I can't get past is, if I want to remove the tableview controller and create a view controller populated with a tableview. I can get the tableview to appear fine, but no matter what I try I can never get it to populate.
In the viewdidload area I can setup the tableview, color the background, do whatever I want to do, but I seem to 'lose' control of it somehow.
In short, would someone please be able to give me the steps involved in correctly changing the tableviewcontroller to a viewcontroller with a tableview in the apple example?
Thank you.
Lian, you need to read the documentation on UITableViewController. http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html
I'm not sure what you mean by "remove the tableview controller and create a view controller populated with a tableview" or why you would want this configuration. If you're having trouble with populating the tableViewController, you just pass in the data, usually from an NSArray or NSDictionary in the cellForRowAtIndexPath method. You either need to select the UITableViewController template when you create the class file or include the UITableViewDataSource and UITableViewDelegate if you're adding a tableView to a ViewController.
If you mean you want to change the view controller on screen, then you're looking to pop to another view using the navigation controller.
I created a view Called ProgrammaView that appears when a row of a table is clicked.
This view has a UILabel, a UIImageView and a UITextView.
Now.
ProgrammaView's Outlets have to be changed by the parameter passed to a method of the view called iniz.
in this
image there is first the ProgrammaView.h and then the method iniz.
The problem is that the label and other stuff doesn't change!
I checked 3 million times that everything between the xib file and the controller is linked.
The trick to call iniz in the other viewcontrollers works well in other part of the program so i think is not that the problem.
Thank you in advance!
You need to call setNeedsDisplay to indicate that the view should be redrawn.
My understanding is that you start up and show view after that you update the values and expect the view to display new values.
You need to call setNeedsDisplay to indicate that the view should be redrawn. Try to add it at the end of your iniz method.
See apple doc.