I’m trying to update a label on a parent view, but I don’t seem to be able to figure it out. My app is a Master/Detail type app. Within the Detail view, I have a UIScrollView, with 5 or so new view controllers inside, each displaying an image.
When an image is touched, I want the label on the Detail view to be updated. In my custom View Controller.h I have the following:
#import <UIKit/UIKit.h>
#import "UltimateRageAppDelegate.h"
#import "DetailViewController.h"
@interface MyViewController : UIViewController {
DetailViewController *vc;
}
@property (nonatomic, retain) DetailViewController *vc;
@end
And in my View Controller.m file I have:
#import "MyViewController.h"
@implementation MyViewController
@synthesize vc, imageShow, imageName;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
vc.clipboardLabel.text = @"DID THIS WORK?";
NSLog(@"touches ended");
}
@end
I can’t figure out why this doesn’t work. I’ve declared and synthesised an IBOutlet clipboardLabel in my DetailViewController, and I can update the label from within DetailViewController no problems.
It looks like you’ve not set your
vcproperty properly. You should set it when you are creating yourMyViewControllerinstance.This is assuming that you are in
DetailViewController.