I have a FBLogin (Facebook SDK) button I am using in a view being replicated throughout many of my view controllers. It seems I cannot set a UIView as a delegate to the Facebook SDK, so I am trying to create a seperate ViewController to handle the delegate functions of the Facebook SDK.
Header file:
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
@class AppDelegate, FBDelegateViewController;
@interface UserView : UIView {
AppDelegate *appDelegate;
IBOutlet UIView *contentView;
IBOutlet UIImageView *userImage;
IBOutlet UILabel *firstName;
FBDelegateViewController *fbDelegate;
IBOutlet FBLoginView *FacebookLogin;
}
@property (nonatomic, strong) IBOutlet UIView *contentView;
@property (nonatomic, strong) IBOutlet UILabel *firstName;
@property (nonatomic, strong) AppDelegate *appDelegate;
@property (nonatomic, strong) FBDelegateViewController *fbDelegate;
Currently in my implementation I am doing the following:
#import "UserView.h"
#import "AppDelegate.h"
#import "FBDelegateViewController.h"
#import <FacebookSDK/FacebookSDK.h>
@implementation UserView
@synthesize contentView, firstName, appDelegate, fbDelegate;
- (void)awakeFromNib {
fbDelegate = [[FBDelegateViewController alloc] init];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[NSBundle mainBundle] loadNibNamed:@"UserView" owner:self options:nil];
[self addSubview:self.contentView];
[userImage.layer setCornerRadius:21.5];
[FacebookLogin setDelegate:fbDelegate];
}
@end
The application crashes with the following:
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setDelegate:]: unrecognized selector sent to instance 0xa5e4f80'*
In interface builder the UIView that contains the FBLogin item is set.
I also tried delegation with the UIView as well, but it looks like a UIView cannot be a delegate for a FBLogin?
Sorry, new territory here. Typically have used the associated view controller as a delegate - but want to understand external delegation.