简体   繁体   中英

UIButton won't hide/unhide

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 ??

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM