-4

だから私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];
}

上記は、この質問に関係する可能性のあるコードの部分です。

4

1 に答える 1

0
VC1 *vc = [[VC1 alloc] init];//Allocate VC1 in appDelegate, if you allocate VC1 in VC2, then it allocates new instance. 


AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (app.vc.monthly.enabled)//chk button state
{
}
于 2013-05-23T11:33:49.537 に答える