我有以下代码,它是用于语言选择选项的 segmentedControl。案例 0 用于英语,案例 1 用于希腊语,然后传递给 a UITextView
。问题是,每次我按下案例 1 或 0 的按钮时,我都必须返回上一个视图控制器,它是一个表格视图控制器,然后返回到“detailViewController”以显示正确的语言。有没有办法做到这一点而无需在视图控制器之间来回切换?诸如小动画或刷新或重新加载方法之类的UITextView
.
int a;
- (IBAction)languageSeg:(id)sender {
switch (((UISegmentedControl *)sender).selectedSegmentIndex) {
case 0:
a=0;
break;
case 1:
a=1;
break;
default:
break;
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
UIImage *saladImage = [UIImage imageNamed:@"salad.jpg"];
UIImage *fishImage = [UIImage imageNamed:@"fish.jpg"];
[textDetail setScrollEnabled:YES];
[textDetail setContentSize:CGSizeMake(320, 190)];
//Switch the UIImages and UILabel based on item
switch (itemNumber) {
case 0:
itemName.text = @"Salad";
itemPic.image = saladImage;
self.title = @"Salads";
if (a==0){
textDetail.text = @"description in english";
}
if (a==1){
textDetail.text = @"description in greek";
}
break;
case 1:
// etc.