enable button from other uiview controller class - iphone

I am trying enable button from uiviewcontroller class of other uiviewcontroller but i cant able to enable it. Here is code that i am doing
#implementation InAppClass
- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
if ([transaction.payment.productIdentifier isEqualToString:idstring])
{
generateAdviceViewController *objgenerate= [[generateAdviceViewController alloc]init ];
[objgenerate enableDisableMethod];
[objgenerate release];
}
}
#end
#implementation generateAdviceViewController
-(id)enableDisableMethod
{
[self->generateButton setEnabled:TRUE];
return self;
}
#end
Am i doing wrong?

Looks like you enabling generate button before generateAdviceViewController's view is loaded... Refer to this view after you created generateAdviceViewController like this:
[objgenerate view];
And then call enableDisableMethod.
The code looks strange. Is it just example?

Related

it possible to Pass Data with popViewControllerAnimated?

I came across an interesting problem, i have main ViewController let's call him MainVC with navigationController and i am doing performSegueWithIdentifier from him to Mine second ViewController let's call him SecVC. so when i am trying to do the popViewControllerAnimated i want to pass some data from the SecVC to the MainVc.. i know i can do it with appDelegate Param or with singletons class but my question is : can i do it with more Elegant solution? like i use prepareForSegue and use local parmeters..
Thank you...
The best way to do it is by using a delegate.
//SecVCDelegate.h
#import <Foundation/Foundation.h>
#protocol SecVSDelegate <NSObject>
#optional
- (void)secVCDidDismisWithData:(NSObject*)data;
#end
//SecVC.h
#import <UIKit/UIKit.h>
#import "SecVSDelegate.h"
#interface SecVC : UIViewController
/** Returns the delegate */
#property (nonatomic, assign) id<SecVSDelegate> delegate;
#end
//SecVC.M
...
- (void) dealloc
{
...
delegate = nil
...
}
When ever you popViewControllerAnimated, right after it (or before it) you do this
if(_delegate && [_delegate respondsToSelector:#selector(secVCDidDismisWithData:)])
{
[_delegate secVCDidDismisWithData:myDataObject];
}
And in the MainVC you must be certain that you implement the delegate function
//MainVC.m
- (void)secVCDidDismisWithData
{
//do whatever you want with the data
}
To avoid any warnings you must tell that the MainVC class implements the delegate like this:
//MainVC.h
#import "SecVCDelegate.h"
...
#interface MainVC : UIViewController <SecVCDelegate>
...
secVCInstance.delegate = self;
[self.navigationController pushViewController:secVCInstance];
...
While I agree that the best option is to use Delegate,
but still if any one is looking for something different, he can use NSNotificationCenter as an alternative.
In viewDidLoad of MainVC:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(recvData:)
name:#"SecVCPopped"
object:nil];
}
And add method recvData in MainVC.m
- (void) recvData:(NSNotification *) notification
{
NSDictionary* userInfo = notification.userInfo;
int messageTotal = [[userInfo objectForKey:#"total"] intValue];
NSLog (#"Successfully received data from notification! %i", messageTotal);
}
Now in SecVC, before popping, add this line
NSMutableDictionary* userInfo = [NSMutableDictionary dictionary];
[userInfo setObject:[NSNumber numberWithInt:messageTotal] forKey:#"total"];
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:#"SecVCPopped" object:self userInfo:userInfo];
I would do it in one of the following ways, but I'm not sure if it's elegant enough...
In SecVC, add an #property MainVC *mainVC; Use [self.mainVC setSomeValue:...]; before calling [self.navigationController popViewControllerAnimated:...];
Use [self.navigationController viewControllers]; to find out the MainVC *mainVC, and call [mainVC setSomeValue:...]; before the line of code that pop the ViewController.
Is this what you want?
I simply set up a protocol in the view being dismissed (example in Swift):
protocol ExampleTableViewControllerDismissDelegate {
func didDismiss(withData: Any)
}
var delegate: SearchableTableViewControllerDismissDelegate?
You can then call this when you dismiss/pop your view like this
self.navigationController?.popViewController(animated: true)
delegate?.didDismiss(withData: Any)
Then in the view being dismissed to (the parent in the hierarchy), we can conform to the delegate and essentially get a callback with the data after the view has been dismissed.
//MARK: ExampleTableViewControllerDismissDelegate
func didDismiss(withData: Any) {
//do some funky stuff
}
And don't forget to subscribe to the delegate in the parent view by using
viewController.delegate = self
There is another way to pass data between views including popViewControllerAnimated and it's with a global var instance, so If you modify that Var in your detail view and after do the popViewControllerAnimated, you can call the new data in the viewWillAppear method.
The first step is declare the Global var in main.h
NSMutableArray * layerList;
And now you have to call it in detail view.
SecondView.m
extern NSString *layerList;
SecondView.h
-(void)back{
layerList = #"Value to send";
[self.navigationController popViewControllerAnimated:YES];
}
Now you can use the information in the Master View after detect the pop action.
FirstView.m
extern NSString *layerList;
FirstView.h
-(void)viewWillAppear:(BOOL)animated{
NSLog(#"This is what I received: %#",layerList);
}

Object is nil when called from another class

I want to change properties of another object, when a method is called in another class.
The code to change the properties of this object sits in a method of the first class, and works when calling it from it's own class, but when called from the other class the object in the method returns nil.
Here is the code:
ViewController.h
#interface ViewController : UIViewController {
UIView *menuView; //the object
}
#property (nonatomic, retain) IBOutlet UIView *menuView;
-(void)closeMenu; //the method
#end
ViewController.m
#implementation ViewController
#synthesize menuView;
-(void)closeMenu{
[menuView setFrame:CGRectMake(menuView.frame.origin.x, -menuView.frame.size.height, menuView.frame.size.width, menuView.frame.size.height)];
NSLog(#"%f", menuView.frame.size.height); //returns height when method is called from it's own class. But returns 0 (nil) when called from the other class.
}
SDNestedTableViewController.h (nothing too important, but might help?)
#interface SDMenuViewController : SDNestedTableViewController{
}
SDNestedTableViewController.m
#import "SDMenuViewController.h"
#import "ViewController.h"
- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem
{
ViewController *firstViewController = [[[ViewController alloc] init] autorelease];
SelectableCellState state = subItem.selectableCellState;
NSIndexPath *indexPath = [item.subTable indexPathForCell:subItem];
switch (state) {
case Checked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Checked\"", indexPath);
[firstViewController closeMenu]; //called from other class
break;
case Unchecked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Unchecked\"", indexPath);
break;
default:
break;
}
}
What you posted looks like:
-(void)closeMenu{
// menuView is never initialized, == nil
[nil setFrame:CGRectMake(0, -0, 0, 0)];
NSLog(#"%f", 0); //returns height when method is called from it's own class. But returns 0 (nil) when called from the other class.
}
So you are doing NSLog(#"%f", 0);.
If you do load the view by accessing the view property, the menuView will be initialized by IB rules.
For the details of viewController view loading/unloading see the reference docs.
I think this may help you.
At Your AppDelegate class, you have to declare an object of ViewController class. Make it as a property of the YourAppDelegate class. like below. (This would import ViewController class and creates a shared object of YourAppDelegate class so that you can access the members of YourAppDelegate class globally by simply importing the YourAppDelegate.h).
#import "ViewController.h"
#define UIAppDelegate ((YourAppDelegate *)[UIApplication sharedApplication].delegate)
#interface YourAppDelegate : NSObject <UIApplicationDelegate>
{
ViewController *objViewController;
}
#property (nonatomic, retain) ViewController *objViewController;
#end
And synthesize the property at YourAppDelegate.m file.
#implementation YourAppDelegate
#synthesize objViewController;
#end
Then the tricky part is, you have to backup the object of ViewController class in the YourAppDelegate class at the time you are loading the ViewController class.
For that first import the YourAppDelegate.h in the ViewController.h class and at the ViewController.m implement viewWillAppear: delegate as follows.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIAppDelegate.objViewController = self;
}
Then at SDNestedTableViewController.m,
#import "SDMenuViewController.h"
#import "ViewController.h"
- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem
{
ViewController *firstViewController = (ViewController *)UIAppDelegate.objViewController;
if(firstViewController && [firstViewController isKindOfClass:[ViewController class]])
{
SelectableCellState state = subItem.selectableCellState;
NSIndexPath *indexPath = [item.subTable indexPathForCell:subItem];
switch (state) {
case Checked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Checked\"", indexPath);
[firstViewController closeMenu]; //called from other class
break;
case Unchecked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Unchecked\"", indexPath);
break;
default:
break;
}
}
}
Try this way. I am not saying this as the right way but, this should works. Glad if this helps you.
EDIT 2:
Well, you shipped your code over to me, so now I can no longer say that I don't have enough information to solve your problem.
Let's see.
Now I see that your ViewController is the rootViewController of your app, like so:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Good, now how does the ViewController relate to your SDNestedTableViewController?
You have this in your ViewController's viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
SDMenuViewController *mvc = [[[SDMenuViewController alloc] initWithNibName:#"SDNestedTableView" bundle:nil] autorelease];
[self addChildViewController:mvc];
[mvc didMoveToParentViewController:self];
[menuView addSubview:mvc.view];
// Some other stuff with gesture recognizers I'm omitting...
[self openMenu];
}
Alright, so it looks like SDMenuViewController is the child of ViewController. Now, you have a method in SDMenuViewController called item:subItemDidChange:
- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem
{
ViewController *firstViewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
SelectableCellState state = subItem.selectableCellState;
NSIndexPath *indexPath = [item.subTable indexPathForCell:subItem];
switch (state) {
case Checked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Checked\"", indexPath);
//close the menuView
[firstViewController closeMenu];
break;
case Unchecked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Unchecked\"", indexPath);
break;
default:
break;
}
}
So, you want the reference back to the existing ViewController object, right? Because right there you're making another one. So, you can do this:
ViewController *firstViewController = self.parentViewController;
That gets you a reference to SDMenuViewController's parent, which is the instance of ViewController. This property is set when you do your addChildViewController: call.
Okay, this is confusing though:
In your post, you say that your item:subItemDidChange: method is in SDNestedTableViewController, but in the code you sent me it's in the SDMenuViewController.
In the SDNestedTableViewController, I found this method:
- (void) mainItem:(SDGroupCell *)item subItemDidChange: (SDSelectableCell *)subItem forTap:(BOOL)tapped
{
if(delegate != nil && [delegate respondsToSelector:#selector(item:subItemDidChange:)] )
{
[delegate performSelector:#selector(item:subItemDidChange:) withObject:item withObject:subItem];
}
}
So it looks like you're not using the same code as in the original post, but close enough, whatever.
Now, if you want to get a reference to the ViewController instance from anywhere in the app, not just your SDMenuViewController (which happens to be the child of the ViewController instance) you should use #Mathew Varghese's answer.
Here's a restatement of this method:
Add the line + (AppDelegate *)instance; to your AppDelegate.h file.
Add the following method to your AppDelegate.m file.
Like so:
+ (AppDelegate *)instance
{
AppDelegate *dg = [UIApplication sharedApplication].delegate;
return dg;
}
Then, in whatever object you want that reference, you #import AppDelegate.h and say ViewController *vc = AppDelegate.instance.firstViewController;
Anyway, it's just another way of saying what Mathew mentioned earlier.
the problem is:
- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem {
ViewController *firstViewController = [[[ViewController alloc] init] autorelease];
...
[firstViewController closeMenu];
}
When you call closeMenu from there, it is never initialized, because not enough time has passed to initialize view of view controller, viewDidLoad method of your firstViewController is not called at this point either. menuView is not created from nib either, so this is the reason why it is nil.
Maybe for some reason there might be a delay long enough so menuView is created, but this is not how you should do things in iOS.
So, if you don't want to show your menuView, just add some boolean value to your firstViewController and instead of closeMenu do:
firstViewController.shouldCloseMenu = YES;
Then in your ViewController in viewDidLoad method do something like:
if (self.shouldCloseMenu ) {
[self closeMenu];
}
Maybe this is not the best way to do it, but now you have an idea how it suppose to work.
I believe your problem is the related to the way you have initialized the viewController.
Instead of
ViewController *firstViewController = [[[ViewController alloc] init] autorelease];
use
ViewController *firstViewController = [[[ViewController alloc] initWithNibName:#"yourNibName" bundle:nil] autorelease];
I'm assuming you have a nib because you are using an IBOutlet. But I believe the IBOutlet is never setup because you have not loaded the nib file.
Also double check your IBOutlet connection with interface builder and use "self.menuView"
I would suggest you to solve this problem in the following steps.
Do not use any instance or variable of firstViewController in the SDMenuViewController.
In the case check block, post a message to the NSNotificationCenter
In the ViewController register the message with the same message Id, use the closeMenu method as its handler.
For me, use the message center to dispatch the handling can decouple the relationship between controllers. This is a better way that you would concern less about the lifecycle of the controller within another one.
Hope it would be helpful.
There is a difference between alloc-init'ing a ViewController and alloc-init'ing that view controller's properties.
Regarding your second example (calling from another class). Your current code indicates that you alloc-init firstViewController, but then don't do anything with it. Assuming you have not overriden your ViewController's init method, its properties and iVars should be nil (or undefined at worst). You need to alloc-init your firstViewController.menuView first. I.e:
firstViewController.menuView = [[UIView alloc] initWithFrame]; // Don't do this.
The problem with this approach is that you're setting up firstViewController's properties form another class, and that's generally fairly average design practice. This required setup would usually happen in viewDidLoad but because you haven't done anything with firstViewController yet, it never gets called.
In contrast, when you call closeMenu from its own View Controller, the odds are you are actually doing something with the view and viewDidLoad (or wherever menuView = [[UIView alloc] init];is found) is called first, thus initialising your menuView object.
You need to ensure that your menuView object is initialised first before you try and do anything with it, just initialising the View Controller that contains it is not enough.
#import "SDMenuViewController.h"
#import "ViewController.h"
- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem
{
// why are we allocating this object here, if it is only required in case Checked :
ViewController *firstViewController = [[[ViewController alloc] init] autorelease];
SelectableCellState state = subItem.selectableCellState;
NSIndexPath *indexPath = [item.subTable indexPathForCell:subItem];
switch (state) {
case Checked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Checked\"", indexPath);
[firstViewController closeMenu]; //called from other class
break;
case Unchecked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Unchecked\"", indexPath);
break;
default:
break;
}
}
Change it to
#import "SDMenuViewController.h"
#import "ViewController.h"
- (void) item:(SDGroupCell *)item subItemDidChange:(SDSelectableCell *)subItem
{
// why are we allocating this object here, if it is only required in case Checked :
SelectableCellState state = subItem.selectableCellState;
NSIndexPath *indexPath = [item.subTable indexPathForCell:subItem];
switch (state) {
case Checked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Checked\"", indexPath);
// here no need to put object in autorelease mode.
ViewController *firstViewController = [[ViewController alloc] init];
[firstViewController closeMenu]; //called from other class
[firstViewController release];
break;
case Unchecked:
NSLog(#"Changed Sub Item at indexPath:%# to state \"Unchecked\"", indexPath);
break;
default:
break;
}
}
try to remove UIView *menuView; //the object from the interface file
#interface ViewController : UIViewController {
// try to remove this line
UIView *menuView; //the object
}
and update this method
-(void)closeMenu{
[self.menuView setFrame:CGRectMake(self.menuView.frame.origin.x, -self.menuView.frame.size.height, self.menuView.frame.size.width, self.menuView.frame.size.height)];
NSLog(#"%f", self.menuView.frame.size.height);
}
Everything is correct, change the -(void)closeMenu method like...
-(void)closeMenu
{
menuView=[[UIView alloc]initWithFrame:CGRectMake(50.0,50.0,200.0,200.0)]
NSLog(#"%f", menuView.frame.size.height); //returns height when method is called from it's own class. But returns 0 (nil) when called from the other class.
}
Try this and let me know.
I suggest you use this:
if(menuView) {
[menuView setFrame:CGRectMake(menuView.frame.origin.x, -menuView.frame.size.height, menuView.frame.size.width, menuView.frame.size.height)];
} else {
NSLog(#"menuView is nil");
}

How to pass value to a variable defined in parent class from child class?

My home page has a toolbar with three buttons home,notification and login. I want notification button show only when user loged In. here is my code
//Parent class
#interface Toolbar : UIViewController {
UIToolbar *toolBar;
UIButton *home;
UIButton *notification;
UIButton *login;
BOOL signIn;
}
#property(nonatomic,assign)BOOL signIn;
#property(nonatomic,retain)UIButton *home;
#property(nonatomic,retain)UIButton *notification;
#property(nonatomic,retain)UIButton *login;
#property(nonatomic,retain)UIToolbar *toolBar;
-(IBAction)Home:(id)sender;
-(IBAction)LogIn:(id)sender;
//Toolbar.m
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
if (!signIn) {
[notification setHidden:YES];
[login setHidden:NO];
}else {
[notification setHidden:NO];
[login setHidden:YES];
}
}
//Child class
#interface LoginScreen : Toolbar{
LoginScreen.m
-(IBAction)SignIn{
if ([emailField.text isEqualToString:#"m"] && [passwordField.text isEqualToString:#"a"]) {
NSLog(#"loggedIN");
signIn=YES;
Home *home=[[Home alloc]initWithNibName:#"Home" bundle:nil];
[self.navigationController pushViewController:home animated:YES];
[home release];
}else {
//other condition
}
}
problem is I am able to to go back to home but signIn condition is not working. please guide me . Thanks..
Use Protocols (delegate mechanism) to send back the value to the parent view controller.
See here for some sample. Also here
You can find many samples for this in every Apple sample application.
I have also give you a Sample Application. Go through that and modify the protocol as per your need

UISegmentedControl change event not firing in iOS5

I have a UISegmentedControl whose "Value changed" event is wired up in Interface Builder to call my controller's -(IBAction)segmentChangeAction:(id)sender;
When the user taps on the control to change the selected segment, as expected segmentChangeAction is called whether in iOS4 or iOS5.
When I programmatically change the selected segment through segmentedControl.selectedSegmentIndex = newIndex;, on iOS4 segmentChangeAction is called and the segment reflects the new selection. However on iOS5 segmentChangeAction is not called, yet the segment does reflect the new selection.
Is this a change in iOS5? Is there anything I can do to get segmentChangeAction called on iOS5 when I programmatically change the selection?
This is a change in iOS 5 in order for UISegmentedControl to be consistent with all other controls.
The idea is that the action should only fired automatically as a result of user interaction. Prior to iOS 5, UISegmentedControl's actions would be fired because of user interaction and programmatic interaction. However, initiating the change programmatically means that you can also do [myControl sendActionsForControlEvents:UIControlEventValueChanged] yourself.
However, you have to be careful with this. Say you do:
[segmentedControl setSelectedSegmentIndex:newIndex];
[segmentedControl sendActionsForControlEvents:UIControlEventValueChanged];
If you build and run this on iOS 5, it works as you expect. If you build and run this on iOS 4, you'll get your actions fired twice (once when you setSelectedSegmentIndex and again when you sendActions...).
The way around this is to do some sort of guard. This could be a runtime check to indicate that you're running on an iOS 5+ device, or could even be something more mundane, like this:
// changingIndex is a BOOL ivar
changingIndex = YES;
[segmentedControl setSelectedSegmentIndex:newIndex];
changingIndex = NO;
[segmentedControl sendActionsForControlEvents:UIControlEventValueChanged];
and then in your action method...
- (void)segmentedControlSelectedIndexChanged:(id)sender {
if (!changingIndex) {
// your action code here, guaranteed to only run as a result of the sendActions... msg
}
}
I found another way, probably bit easier to understand
you can extend UISegmentedControl and add target action in init methods and call a delegate method to trigger the value change
here is the example code
header file looks like this
#import <UIKit/UIKit.h>
#class CGUISegmentedControl;
#protocol CGUISegmentedControlDelegate <NSObject>
#optional
- (void) segmentedControl:(CGUISegmentedControl *) control valueChangedTo:(NSInteger) nValue;
#end
#interface CGUISegmentedControl : UISegmentedControl
#property (nonatomic,unsafe_unretained) id <CGUISegmentedControlDelegate> delegate;
#end
.m file
#import "CGUISegmentedControl.h"
#implementation CGUISegmentedControl
#synthesize delegate = _delegateAction;
- (void) addTargetAction {
[self addTarget:self action:#selector(indexChanged:) forControlEvents:UIControlEventValueChanged];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addTargetAction];
}
return self;
}
- (id) initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self addTargetAction];
}
return self;
}
- (id) initWithItems:(NSArray *)items {
self = [super initWithItems:items];
if (self) {
[self addTargetAction];
}
return self;
}
- (id) init {
self = [super init];
if (self) {
[self addTargetAction];
}
return self;
}
- (void) indexChanged:(id) sender {
if (_delegateAction && [_delegateAction respondsToSelector:#selector(segmentedControl:valueChangedTo:)])
[_delegateAction segmentedControl:self valueChangedTo:self.selectedSegmentIndex];
}
#end
And you can set the delegate in the calling class

Delegate not being called

I've a viewcontroller "ResultsViewController" with a button called emailbutton. when this button is pressed, i want a function to be called from another view called "Illusions_AppViewController" (both these viewcontrollers are not linked).
Therefore i defined a protocol in the "ResultsViewController.h":
#protocol ResultsViewDelegate <NSObject>
#optional
- (void) resultspage;
#end
#interface ResultsViewController : UIViewController
{
id<ResultsViewDelegate> mydelegate;
UIButton *emailButton;
}
#property(nonatomic,retain) IBOutlet UIButton *emailButton;
#property (nonatomic,assign) id<ResultsViewDelegate> mydelegate;
#end
In the ResultsViewController.m :
-(IBAction)emailButtonPressed:(id)sender
{
NSLog(#"entered emailbuttonpressed");// the app enters this method and gets hanged
if ([mydelegate respondsToSelector:#selector(resultspage)]) {
NSLog(#"entered respondstoselector");// this is never displayed in the log-showing that the delegates doesnt respond to selector
[mydelegate resultspage];
}
}
In my other view, "Illusions_AppViewController.m":
- (void)resultspage{
NSLog(#"Entered results page");
ResultsPageController *resultspagecontroller = [[ResultsPageController alloc] initWithNibName:#"ResultsPageController" bundle:nil];
resultspagecontroller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:resultspagecontroller animated:YES];
}
Would appreciate if anyone can help me with this. I've no clue of why the delegate is not called. the app gets hanged as soon as i press the emailbutton. Thanks!
The implementation/use of delegates is wrong. Please refer to this tutorial.
Hope this helps.
Thanks,
Madhup
or is there any other way to get this done. i just need the results page function to be called whenever the email button is pressed. i tried using this way:
ResultsViewController.m
-(IBAction)emailButtonPressed:(id)sender
{
NSLog(#"entered emailbuttonpressed");
illusions_AppViewController *illusionsview = [[illusions_AppViewController alloc]init];
[illusionsview performSelector:#selector(resultspage)];
}
Now the results page function gets called, but the resultspagecontroller that it needs to display as a modalviewcontroller never appears.the app hangs, and no errors in the console either.
To answer your second question, you are on the right track. Simply create an instance of your Illusions_AppViewController and call the illusionsView method in it instead using:
- (IBAction)emailButtonPressed {
illusions_AppViewController *illusionsview = [[illusions_AppViewController alloc]init];
[illusionsview resultspage];
[illusionsview release];
}