我将UIButton myButton设置为隐藏在viewDidLoad上
在splitviewcontroller中,我有它,所以当我单击tablecell时,某些项目会被解除隐藏,这对我的textviews很有用,但是我的按钮给了我这样的信息:
错误:成员引用基类型void不是结构或联合。
下面是一些代码片段:
- (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;
@endIBAction myButtonPressed in DetailViewController.m是
-(IBAction)myButtonPressed{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
RootViewController *RVC = [storyboard instantiateViewControllerWithIdentifier:@"Root"];
[UIApplication sharedApplication].delegate.window.RootViewController = RVC;
}有谁想过为什么这个按钮不像其他两个人那样?是因为我给了它一个IBAction吗?
发布于 2014-01-30 06:48:18
按钮应该是一个IBOutlet,请纠正它和更新XIB参考,你应该是好的。
@property (nonatomic, weak) IBOutlet UIButton * myButton;如果您正在使用UIButton,请将其链接到XIB。
发布于 2014-01-30 06:46:38
您忘记将IBOutlet放在按钮创建的第一步--它应该是
@property (strong, nonatomic) IBOutlet UIButton *myButton; OR
@property (nonatomic, weak) IBOutlet UIButton *myButton;并与file's owner建立适当的连接。
https://stackoverflow.com/questions/21449554
复制相似问题