0

您好,我有一个包含 3 个 UIButtons 的 nib 文件,我需要在从 nib 加载后在运行时更改按钮的属性,但我不知道我在做什么错。更改布尔值后我也有 NSlog,但我总是在输出中得到“0”。任何帮助谢谢

-(void)SettingBtnPressed:(id)sender
{

    UIButton *btn =(UIButton*)sender;
    UITableViewCell *btncell =(UITableViewCell *)[btn superview];

    if ([[recentActivities objectAtIndex:btn.tag] isKindOfClass:[MeetingSummary class]]) {

        [MainManager getSharedInstance].Summary = [recentActivities objectAtIndex:btn.tag];
        MeetingSummary *ms=[recentActivities objectAtIndex:btn.tag];
        Meeting *m=ms.meeting;


        if(![popoverController isPopoverVisible]){
            lastPoint = sender;
            if (![m.endedDate isEqualToString:@"1/1/0001"]) {

                if (settingpop) {
                    [settingpop release];
                }
                settingpop = [[SettingsPopViewController alloc] initWithNibName:@"SettingsPopViewController" bundle:nil];
                settingpop.start.hidden=YES;
                settingpop.start.enabled=NO;
                NSLog(@"%i",settingpop.start.hidden);
                NSLog(@"%i",settingpop.start.enabled);
                settingpop.btnShowDetail.enabled=NO;
                settingpop.btnShowDetail.hidden=YES;
        //        [settingpop.start removeFromSuperview];
        //        [settingpop.btnShowDetail removeFromSuperview];
                settingpop.view.frame=CGRectMake(0, 0, 250, 54);

            }
            else
            {

                settingpop = [[SettingsPopViewController alloc] initWithNibName:@"SettingsPopViewController" bundle:nil];

            }
            settingpop.delegate = self;
            [settingpop setActivityView:self.view];

            popoverController = [[[UIPopoverController alloc] initWithContentViewController:settingpop] retain];

            [popoverController setPopoverContentSize:CGSizeMake(250.0f, 162.0f)];

            [popoverController presentPopoverFromRect:btn.frame inView:btncell
                         permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        }else{

            [popoverController dismissPopoverAnimated:YES];
        }
    }
}
4

2 回答 2

1

您是在谈论调整 的startbtnShowDetail控件的属性SettingsPopViewController吗?您无法在initWithNibName. 您必须等到视图创建之后,即等到 afterviewDidLoad被调用,因为 NIB 可能直到那时才被加载。

于 2012-11-10T17:21:31.897 回答
1

移动行:

settingpop.view.frame=CGRectMake(0, 0, 250, 54);

行前:

settingpop.start.hidden=YES;
于 2012-11-10T17:40:27.580 回答