gpt4 book ai didi

ios - UIButton 不会隐藏/取消隐藏

转载 作者:行者123 更新时间:2023-11-29 03:17:59 25 4
gpt4 key购买 nike

我将 UIButton myButton 设置为在 viewDidLoad 上隐藏

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

IBAction myButtonPressedDetailViewController.m

-(IBAction)myButtonPressed{

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


}

有人想知道为什么按钮的行为与其他两个不同吗?是不是因为我给了它一个IBAction??

最佳答案

你忘了把 IBOutlet 放在创建按钮的第一个位置,它应该是

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

并为文件的所有者提供正确的连接。

关于ios - UIButton 不会隐藏/取消隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21449554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com