Reputation: 193
I set UIButton
myButton to hidden on viewDidLoad
In a splitviewcontroller
I have it so that when I click on a tablecell
, certain items unhide which works great for my textviews
but my button is giving me this:
ERROR: member reference base type void is not a structure or union
Here is some snippet of code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
detailViewController.myButton.hidden= NO;
detailViewController.textView1.hidden= NO;
detailViewController.textView2.hidden= NO;
}
in the .h file there is
@property (strong, nonatomic) DetailViewController *detailViewController;
in DetailViewController
is where the button and textviews
are declared as
@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>{
IBOutlet UIButton *myButton;
IBOutlet UITextView *textView1;
IBOutlet UITextView *textView2;
}
@property (strong, nonatomic) IBOutlet UITextView *textView1;
@property (strong, nonatomic) IBOutlet UITextView *textView2;
@property (strong, nonatomic) UIButton *myButton;
-(IBAction)myButtonPressed;
@end
IBAction
myButtonPressed
in the DetailViewController.m
is
-(IBAction)myButtonPressed{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
RootViewController *RVC = [storyboard instantiateViewControllerWithIdentifier:@"Root"];
[UIApplication sharedApplication].delegate.window.RootViewController = RVC;
}
Anyone have any thoughts on why the button won't behave like the other two will? Is it because I gave it an IBAction
??
Upvotes: 0
Views: 478
Reputation: 4005
Button should be a IBOutlet and please correct it and update XIB references and you should be good.
@property (nonatomic, weak) IBOutlet UIButton * myButton;
link this to UIButton is XIB if you are using one.
Upvotes: 0
Reputation: 47119
You forget to Put IBOutlet
at the first of button creation it should be
@property (strong, nonatomic) IBOutlet UIButton *myButton; OR
@property (nonatomic, weak) IBOutlet UIButton *myButton;
And give proper connection to file's owner
.
Upvotes: 1