如何使用2维数组设置UI按钮的标记

时间:2011-02-25 06:03:20

标签: iphone

我想用2维数组设置UI按钮的标签 - >

这里是我的代码,不知道我错在哪里。


for(int i = 0 ; i<[arrWeekly_Fetch_DataForLandscapeMode count] ; i++)
{           
    btnLandscape_Button = [UIButton buttonWithType:UIButtonTypeCustom];
    btnLandscape_Button.backgroundColor = [UIColor clearColor];
    btnLandscape_Button.frame = CGRectMake(0,0,200,50);
    [btnLandscape_Button.titleLabel setFont:[UIFont systemFontOfSize:14]];
    btnLandscape_Button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [arrCommonDays[1][i] addObject:[arrWeekly_Fetch_DataForLandscapeMode objectAtIndex:i]];
    [btnLandscape_Button setTag:[1][arrWeekly_Fetch_DataForLandscapeMode objectAtIndex:i]];
    [btnLandscape_Button addTarget:self    action:@selector(btnClick_ForDetailInformation_For_Class_InLandscapeMode:) forControlEvents: UIControlEventTouchUpInside];
            [btnLandscape_Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [viewForDisplayData_OnDaily addSubview:btnLandscape_Button];

            [btnLandscape_Button setTitle:[dictWeeklyData_InLandscape_Mode objectForKey:@"sSubjectCode"] forState:UIControlStateNormal];
        }

1 个答案:

答案 0 :(得分:0)

如果我理解你的arrWeekly_Fetch_DataForLandscapeMode数组是二维数组(数组数组),那么你应该从下一个方法中提取值:

[btnLandscape_Button setTag:[[arrWeekly_Fetch_DataForLandscapeMode objectAtIndex:i] objectAtIndex:1]];

[btnLandscape_Button setTag:[[arrWeekly_Fetch_DataForLandscapeMode objectAtIndex:1] objectAtIndex:i]];

至于你的需求。