nib对象在运行时不会更改

时间:2012-11-10 17:13:04

标签: ios uibutton

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

-(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];
        }
    }
}

2 个答案:

答案 0 :(得分:1)

您是在谈论调整start的{​​{1}}和btnShowDetail控件的属性吗?您无法在SettingsPopViewController后立即访问其控件。您必须等到视图创建后,即等到调用initWithNibName之后,因为在此之前NIB可能尚未加载。

答案 1 :(得分:1)

移动行:

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

settingpop.start.hidden=YES;