ios - Changing UITextView with if statement from IBAction -
i've been searching lot seems can't figure out. i'm pretty new ios development , apologize if doing things wrong.
here situation.
i trying switch content view of detailviewcontroller via button should send next text view or same view different text.
this 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 detailviewcontoller depending on cell i've selected. in detailviewcontroller have button want switch next text instead of me going tableviewcontroller , selecting different cell.
//detailviewcontroller //set title of view self.title = rowname; //set 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 , instance of our detailviewcontroller detailviewcontroller * dvc = [[detailviewcontroller alloc]init]; //set dvc destinationviewcontoller dvc = [segue destinationviewcontroller]; //get indexpath nsindexpath * path = [self.tableview indexpathforselectedrow]; nsstring * thelist = [rowlist objectatindex:path.row]; dvc.rownumber = path.row; dvc.rowname = thelist; }
your question bit confusing. if want switch next case, button, write rownumber ++; in button method, , call method switch statement is.
Comments
Post a Comment