Controlling One View From Another. How?
Hi there, I have a problem that i find very frustrating... I´m currently working on a application using tab bars. I have made it so when you press the tab ar item you are currently in a actionsheet will pop up, giving you options to choose from. What i want is to be able to control a webview in the current tab with the buttons from the actionsheet. So lets say i want to set the url, i would have a button for that etc...
I have read about different techniques of passing data between viewcontrollers and such, but all of them seems to only be how to pass the value of one UITextfield in viewcontroller1 to the UILabel in viewcontroller2. I´m really confused about how to do this.
This is how i´ve done it this far.
I have a subclass of UITabBarController set up with the name TabController. In my TabController.h I have done following.
//TabController.h
#import <UIKit/UIKit.h>
#import "viewcontroller1.h>
@interface TabController : UITabBarController
{
viewcontroller1 *theViewController1 ;
}
@property (nonatomic, retain) viewcontroller1 *theViewController1;
Then i do the following in my TabController.m
//TabController.m
#import <TabController.h>
Here i try to control the webview by refering to the webview in theViewController1 in the method for clickedbuttonatindex like so:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"buttonWithIndex: %d", buttonIndex);
if ((actionSheet.tag == 3) && (buttonIndex == 0))
{
[theViewController1.webView reload];
NSLog(@"Logging When The Method Is Called");
}
I´m able to see that the method is called correctly...
But nothing happens with my webview. I´ve been all around the web, trying to find a solution to this.. But it seems like i cannot find any examples that shows how to control a view from another. I´ve only found the techniques for how to pass data, like strings and such...
Please someone out there, help me.
I would really appreciate some well described code examples of how to do this, as im not that expericenced in programming.
Cheers 🙂
Message was edited by: Klafstad
iPhone 4S, iOS 5.1