我一直在寻找很多,但似乎我无法弄清楚。我对iOS开发非常陌生,如果我的做法完全错误,我很抱歉。用IBAction的if语句更改UITextView
这是情况。
我想通过按钮切换我的DetailViewController的内容视图,该按钮应该将您发送到下一个文本视图或相同的视图,但使用不同的文本。
这是我的头文件。
#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
我的tableViewController重定向到我的DetailViewContoller取决于我选择的单元格。现在在我的DetailViewController中,我有另一个按钮,我想切换到下一个文本,而不是我回到tableViewController并选择一个不同的单元格。
//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;
}
那么问题是什么? – rdelmar 2013-04-06 04:53:34
如何连接我的UIBarbuttonItem按钮以显示下一个单元格上下文,即文本,而不必返回并选择它。 – ZeroOne 2013-04-06 05:00:06
选择此@属性(强,非原子)IBOutlet UIBarButtonItem * rightArrow;应该将我重定向到下一个单元格。所以,如果我在情况下0,我按下按钮,它应该切换到案例1 ...感谢您的帮助顺便说一句。 – ZeroOne 2013-04-06 05:04:40