0

I have a code that load the custom view from a nib file but there is a problem with the variable of that custom view.

- (id)initWithFrame:(CGRect)frame
 { self = [super initWithFrame:frame];
if (self) {
    // Initialization code
    HomeMainView* views = (HomeMainView*)[[[NSBundle mainBundle] loadNibNamed:@"HomeMainView" owner:self options:nil] objectAtIndex:0];
    [self release];

    NSArray* permission = [NSArray arrayWithObjects:@"user_photos",@"publish_stream", nil];

    FBLoginView* fbLogin = [[[FBLoginView alloc] initWithPublishPermissions:permission defaultAudience:FBSessionDefaultAudienceFriends] autorelease];


    [views.FBLogin addSubview:fbLogin];
    [views.homeButton setTitle:@"asdf" forState:UIControlStateNormal];

    self = views;

}
return self;
 }

I am trying to add the fbLogin to the views object generated by the Nib file. The problem is the views.FBLogin generate the errors saying unrecognized selectors.

Does anyone know what is wrong here?

Adrian P
  • 6,479
  • 4
  • 38
  • 55
LittleFunny
  • 8,155
  • 15
  • 87
  • 198
  • [UIView FBLogin]: unrecognized selector sent to instance 0x6e80be0 2012-11-11 18:36:40.153 xxx[1145:16803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView FBLogin]: unrecognized selector sent to instance 0x6e80be0' This is the error it produced *** Call stack at first throw: ( – LittleFunny Nov 11 '12 at 05:51
  • are you sure that `views` is actually an instance of HomeMainView and that your HomeMainView implm. has a getter for an FBLogin view? – foggzilla Nov 11 '12 at 18:14

2 Answers2

1

I had the same problem but it was because I needed to add this to my app delegate didFinishLaunchingWithOptions :

[FBLoginView class]

Without this the UIView was a UIView not an FBLoginView, hence the unrecognized selector.

Typo Johnson
  • 5,974
  • 6
  • 29
  • 40
0

Make sure that you have set the custom class in interface builder for the view. Select the view and press cmd+option+3 and set the custom class.

Nicolinux
  • 169
  • 3
  • 8