だから私VC1.h
は得た:
@property (weak, nonatomic) IBOutlet UIButton *monthly;
これは、クラスに接続されているビューのボタンに接続されていますVC1
。.enabled
別のクラスでこのボタンのプロパティにアクセスするにはどうすればよいですか?
編集:
テーブルビューに接続されたクラスがあります。テーブルビューで特定の行を選択するときに、メインクラスのボタンを無効にしたいと考えています。私が知る必要があるのは、ボタンの現在の状態を取得して別のクラスで無効にする方法だけです。
ボタンからの IBaction:
- (IBAction)monthly:(id)sender {
[monthly setSelected:YES];
yearly.enabled = YES;
if([monthly isSelected])
{
NSLog(@"monthly ON");
[yearly setSelected:NO];
monthly.enabled = NO;
_dateSpecifiedYearButton.hidden = TRUE;
_dateSpecifiedYearButton.enabled = NO;
_dateSpecifiedButton.hidden = FALSE;
_dateSpecifiedButton.enabled = YES;
}
}
Tableview.m :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[popoverSpending dismissPopoverAnimated:YES];
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
if([self.delegate respondsToSelector:@selector(spendingButtonText:)]) {
[self.delegate spendingButtonText:cell.textLabel.text];
}
if (indexPath.row == 2) {
NSLog(@"2");
ViewController *vc = [[ViewController alloc] init];
if (vc.monthly.enabled)
{
vc.monthly.enabled = NO;
vc.yearly.enabled = NO;
}
}
[self dismissViewControllerAnimated:YES completion:nil];
}
上記は、この質問に関係する可能性のあるコードの部分です。