I have read some of the Apple documentation on Navigation based applications and found it much like navigating through one; after drilling down through several "Read more on ....." chapters I'm now a bit lost.
Firstly, I'm not sure I fully grasp how to simply add another view to a project correctly:
Is it the case that you should always create a new view by adding it from the File menu so that you have an .xib file attached to the .h and .m files? If so, when you first create a new project and you have the first view on the storyboard already, along with a .h and a .m file for it, where is the related .xib file? Is there not one because the view is not a custom class?
Secondly, if I am creating views in this way so that I have an .xib file to edit, am I correct that to add a custom class view to storyboard that you add a UITableView, for example, and then select my custom Table View class from the drop-down box in the inspector? If so, if I wanted to edit the appearance of something on the view do I do it in the .xib file or in the view I added to storyboard? I ask this because I can't seem to edit the properties of table cells in a custom table view I have created via the .xib file. There is just a list of example cells with "Brea", "Burlingame, "Canoga Park" etc that can't be selected. Editing them on the storyboard worked, but it seems to be counterintuitive if the custom class is meant to be a table view all set up and calibrated for how I want it to look.
Thirdly, after adding a detail UIView, when I click on something in my table view in the simulator, it loads the view fine and even changes the title of the navigation bar. However, nothing else on my custom UIView appears (which should be an image in a UIImageView, and text in a label). The code I am using to do this, which is inside the TableView .m file is:
...and then in the .m of the UIView:
If I haven't provided a key piece of information that you would need to work out what I'm doing wrong then please let me know; I'm not 100% sure on what is relevant at this point.
Thank you.
Firstly, I'm not sure I fully grasp how to simply add another view to a project correctly:
Is it the case that you should always create a new view by adding it from the File menu so that you have an .xib file attached to the .h and .m files? If so, when you first create a new project and you have the first view on the storyboard already, along with a .h and a .m file for it, where is the related .xib file? Is there not one because the view is not a custom class?
Secondly, if I am creating views in this way so that I have an .xib file to edit, am I correct that to add a custom class view to storyboard that you add a UITableView, for example, and then select my custom Table View class from the drop-down box in the inspector? If so, if I wanted to edit the appearance of something on the view do I do it in the .xib file or in the view I added to storyboard? I ask this because I can't seem to edit the properties of table cells in a custom table view I have created via the .xib file. There is just a list of example cells with "Brea", "Burlingame, "Canoga Park" etc that can't be selected. Editing them on the storyboard worked, but it seems to be counterintuitive if the custom class is meant to be a table view all set up and calibrated for how I want it to look.
Thirdly, after adding a detail UIView, when I click on something in my table view in the simulator, it loads the view fine and even changes the title of the navigation bar. However, nothing else on my custom UIView appears (which should be an image in a UIImageView, and text in a label). The code I am using to do this, which is inside the TableView .m file is:
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
TGDetailViewController *detailViewController = [[TGDetailViewController alloc] initWithNibName:@"TGDetailViewController" bundle:nil];
_currentDrawnCard = [_deck drawCard: [NSNumber numberWithInt:indexPath.row + 1]];
detailViewController.title = _currentDrawnCard.characterName;
[detailViewController giveCard:_currentDrawnCard];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
}
...and then in the .m of the UIView:
Code:
-(void)giveCard:(Card *)card {
_activeCard = card;
_characterPictureView.image = _activeCard.characterStill;
_testText.text = [NSString stringWithFormat:@"%d",_activeCard.strength];
}
If I haven't provided a key piece of information that you would need to work out what I'm doing wrong then please let me know; I'm not 100% sure on what is relevant at this point.
Thank you.