2015-07-18 49 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]; 
相關問題