开发者

Iphone: Calling a function in a view controller from the super view controller?

开发者 https://www.devze.com 2023-02-03 20:30 出处:网络
Hi Im new to Iphone App development. I have a Tab bar based application. In one of the Tabs I have a Custom Navigation View controller with a Custom Table View Controller. How do I call a function in

Hi Im new to Iphone App development. I have a Tab bar based application. In one of the Tabs I have a Custom Navigation View controller with a Custom Table View Controller. How do I call a function in the Custom Table View Controller from the viewDidLoad method of the Super Controller i.e the Cus开发者_StackOverflowtom Navigation View Controller?

Thanks


How are you instantiating the Custom Table View Controller? Is it a Nib or programmatically.

If the former use an IBOutlet from the Custom Navigation View Controller to the instance of the custom TV controller.

If the latter just keep a ivar handle to the custom TV controller when you create it.

as in self.ctvc = [[[MyCVTV alloc] initWithNibName:nil bundle:nil] autorelease];

where ctvc is @property (readwrite,retain) MyCTVC *ctvc;

Dont forget to release in the dealloc overide

-(void)dealloc {
self.ctvc = nil;
[super dealloc];
}

So when you wish to use the method from the viewDidLoad method. [ctvc doSomething:thing]

But UINavigationController isnt designed for sub-classing . http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

You should rethink your object structure

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号