1

DataPass と ViewController という 2 つのビュー コントローラーがあります。DataPass から ViewController にデータを渡したいです。ViewController にラベルがあり、ViewController に UIButton があり、それ自体を却下し、却下中にデータを DataPass のラベルに渡します。

できませんでした。助けてください。これが私のコードです:

ViewController.h

@interface ViewController : UIViewController
- (IBAction)sayfaGec:(id)sender;
@property (retain, nonatomic) IBOutlet UILabel *label;
+(ViewController *)hop;

ViewController.m

+(ViewController *)hop{
    static ViewController *myInstance = nil;
    if (myInstance == nil){
        myInstance = [[[self class]alloc]init];
        myInstance.label.text = @"test";
    }
    return myInstance;
}

DataPass.h

- (IBAction)sayfaKapat:(id)sender;

DataPass.m

- (IBAction)sayfaKapat:(id)sender {
    [ViewController hop].label.text = @"ddsg";
    [self dismissModalViewControllerAnimated:YES];
}
4

1 に答える 1

0
ViewController.h

- (void)setLabelData:(NSString:)aString;

ViewController.m

- (void)setLabelData:(NSString:)aString{
    [yourLabel setText:aString];
}

DataPass で次のように言います。

ViewController *vContr = [[ViewController aloc]init];
[vContr setLabelData: @"asta la vista baby!"];
[self.view addSubview:vContr.view];
于 2012-07-28T18:55:03.683 に答える