I've been searching a lot but it seems like I just can't figure it out. I'm pretty new to iOS development and I apologize if I am doing things completely wrong.
Here is the situation.
I am trying to switch the content view of my DetailViewController via button that should send you to the next text view or the same view but with different text.
This is my header file.
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextView *rowContent;
@property int rowNumber;
@property (strong, nonatomic) NSString * rowName;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *rightArrow;
@end
My tableViewController redirects me to my DetailViewContoller depending on which cell I've selected. Now in my DetailViewController I have another button that I want to switch to next text instead of me going back to the tableViewController and selecting a different cell.
//DetailViewController
//set the title of the view
self.title = rowName;
//set the UITextView basec on rowNumber
switch (rowNumber) {
case 0:
rowContent.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"file" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
break;
case 1:
rowContent.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"file1" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
break;
case 2:
rowContent.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"file2" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
break;
case 3:
rowContent.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"file3" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
break;
default:
break;
//TableViewController
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//create and instance of our DetailViewController
DetailViewController * DVC = [[DetailViewController alloc]init];
//set the DVC to the destinationViewContoller
DVC = [segue destinationViewController];
//get the indexPath
NSIndexPath * path = [self.tableView indexPathForSelectedRow];
NSString * theList = [rowList objectAtIndex:path.row];
DVC.rowNumber = path.row;
DVC.rowName = theList;
}