I have a problem with an app I am creating. FYI I am a newbie and this is my first major project so I might be missing some basic mechanics/ information. But here it is, I am wondering how I can access the instance of the view controller thats created automatically in storyboard via segue. The basic design of the app is that I have a main view but then the user presses a button to go into an information view. This information view contains a table view which contains dynamic table cells. Each cell has a two labels and a button. The way I want to have it is when the user presses the button that I have connected to the custom table view cell class I want it to get the information and then segue to another view controller called schedule view. The problem I am having is that I don't know how to get the instance of of the information view that is automatically created. I'm trying to use the method [self performSegueWithIdentifier
"toSchedule" sender: self];
Any help would be much appreciated.
[EDIT]
Here is my code:
Here is code for the tableviewcellclass
Any help would be much appreciated.
[EDIT]
Here is my code:
Code:
#import "TeacherViewController.h"
#import "SchoolStaff.h"
#import "ClassViewCell.h"
@interface TeacherViewController ()
@end
@implementation TeacherViewController
-(IBAction)returned:(UIStoryboard *) segue
{
//what the heck
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _classList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"classViewCell";
ClassViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
int row = [indexPath row];
cell.Period.text = _classList[row][0];
cell.cName.text = _classList[row][1];
return cell;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view
_datTeacher = [[[SchoolStaff sharing]fList]objectAtIndex:2];
_freePeriods.text = _datTeacher.freePeriods;
_classesTaught.text = _datTeacher.classesTaught;
_teacherName.text = _datTeacher.tname;
_department.text = [[NSString alloc] initWithFormat:@"%@%@",_datTeacher.department, @" Department"];
_wayToReach.text = _datTeacher.toReach;
_funFact.text = _datTeacher.funFact;
_room.text = _datTeacher.room;
_teacherImage.image = [UIImage imageNamed: [[NSString alloc] initWithFormat:@"%@%@",_datTeacher.tname, @".TIF"]];
_classList = _datTeacher.cList;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
-(void) segueMethod
{
[self performSegueWithIdentifier:@"toSchedule" sender: self];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"Classes:";
}
@end
Here is code for the tableviewcellclass
Code:
@interface ClassViewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *Period;
@property (strong, nonatomic) IBOutlet UILabel *cName;
- (IBAction)buttonIsPressed:(id)sender;
//Want segue to take place^^
@end
Last edited by a moderator: