[英]UIButton won't hide/unhide
I set UIButton
myButton to hidden on viewDidLoad
我将UIButton
myButton设置为在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: 在splitviewcontroller
我有这样,当我点击一个tablecell
,某些项目取消隐藏它的伟大工程,为我textviews
但我的按钮,给我这个:
ERROR: member reference base type void is not a structure or union 错误:成员引用基本类型void不是结构或联合
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 在.h文件中
@property (strong, nonatomic) DetailViewController *detailViewController;
in DetailViewController
is where the button and textviews
are declared as 在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
IBAction
myButtonPressed
in the DetailViewController.m
is DetailViewController.m
IBAction
myButtonPressed
是
-(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
?? 是因为我给了它IBAction
吗?
You forget to Put IBOutlet
at the first of button creation it should be 您忘记将IBOutlet
放在按钮创建的第一个位置了
@property (strong, nonatomic) IBOutlet UIButton *myButton; OR
@property (nonatomic, weak) IBOutlet UIButton *myButton;
And give proper connection to file's owner
. 并与file's owner
建立适当的连接。
Button should be a IBOutlet and please correct it and update XIB references and you should be good. Button应该是IBOutlet,请更正它并更新XIB参考,您应该会很好。
@property (nonatomic, weak) IBOutlet UIButton * myButton;
link this to UIButton is XIB if you are using one. 如果您使用的是XIB,则将其链接到UIButton。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.