2015-07-18 23 views
-1

我已经在ViewController和DetailViewController上设置了一个字段和一个按钮,如果数字小于10,我有一个标签设置为接收字符串“A”,如果数字小于10,则设置为“B”。但是,im我不确定如何访问它以显示结果。我至今:如何使用方法作为视图的标签返回?

#import "ViewController.h" 
#import "ResultViewController.h" 


@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 

    ResultViewController *resultController = (ResultViewController *)segue.destinationViewController; 
    resultController.segueLabel = self.fieldLabel.text; 

} 

- (NSString *)number:(int)value { 
    int intVal = [[self.fieldLabel text] intValue]; 
    if (intVal < 10) { 
     return @"a"; 
    } 
     else { 
      return @"b"; 
     } 
} 

- (IBAction)showResultView:(id)sender { 
} 

@end 
+1

不能告诉你在问什么,因为我没有看到你_doing_你'号什么:'方法。你想把这些信息发给谁? – matt

+0

@matt我想用这种方法在下一个视图中显示@“a”或@“b”作为标签。目前该标签正在接收插入在self.fieldLabel.text字段中的文字,但我不希望来自该字段的信息,我需要将接收的方法编号的结果 – user1370624

回答

2

如果你想叫你的number方法,然后调用它!取而代之的

resultController.segueLabel = self.fieldLabel.text; 

这听起来像你想说

resultController.segueLabel = [self number:0];