I want to set tag of UIbutton with 2 dimensional arra开发者_Python百科y ->
Here my code, don't know where I am wrong.
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];
}
If I understood correctly that your arrWeekly_Fetch_DataForLandscapeMode array is a 2 dimensional one (array of arrays) then you should extract values from it the next way:
[btnLandscape_Button setTag:[[arrWeekly_Fetch_DataForLandscapeMode objectAtIndex:i] objectAtIndex:1]];
or
[btnLandscape_Button setTag:[[arrWeekly_Fetch_DataForLandscapeMode objectAtIndex:1] objectAtIndex:i]];
as for your needs.
精彩评论