2014-01-30 46 views
0

我设置UIButton为myButton到隐藏在viewDidLoad的UIButton不会隐藏/显示

splitviewcontroller我有这样,当我点击一个tablecell,某些项目取消隐藏这对于我textviews的伟大工程,但我的按钮给我这个:

ERROR: member reference base type void is not a structure or union

下面是一些代码片段:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

{ 

    if (indexPath.row == 0) { 



     detailViewController.myButton.hidden= NO; 
     detailViewController.textView1.hidden= NO; 
     detailViewController.textView2.hidden= NO; 

    } 

在.h文件中有

@property (strong, nonatomic) DetailViewController *detailViewController; 
DetailViewController

是在按钮和textviews被声明为

@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 

IBActionmyButtonPressedDetailViewController.m

-(IBAction)myButtonPressed{ 

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    RootViewController *RVC = [storyboard instantiateViewControllerWithIdentifier:@"Root"]; 
    [UIApplication sharedApplication].delegate.window.RootViewController = RVC; 


} 

任何人有,为什么按钮将不会表现任何想法像其他两个会?是因为我给了它IBAction ??

+0

检查UIButton声明。它不是以正确的方式。 –

回答

0

按钮应该是一个IBOutlet中,并请纠正和更新XIB参考,你应该是好的。

@property (nonatomic, weak) IBOutlet UIButton * myButton; 

将此链接到UIButton是XIB,如果您使用的是XIB。

+0

谢谢,多么粗心的错误。我接受这是因为它是在后面的评论之前发布的! –

+0

但是,我的按钮现在崩溃了,不会更改为故事板...当我将其更改为(非原子,弱)时,会受到这种影响吗? **我刚刚检查过,它仍然崩溃......有关为什么的任何想法? –

+0

什么是崩溃堆栈 – Retro

1

你忘了把IBOutlet在第一按钮创造它应该是

@property (strong, nonatomic) IBOutlet UIButton *myButton; OR 
@property (nonatomic, weak) IBOutlet UIButton *myButton; 

,分给file's owner正确连接。

+1

非常感谢你! –