我使用故事板在 Ios5 中创建了一个新项目,并且我的项目有一个 UIPickerView。
我创建了一个数据源和委托,但我找不到文件所有者在 IOs5 中建立连接。我应该与什么建立联系?
我使用故事板在 Ios5 中创建了一个新项目,并且我的项目有一个 UIPickerView。
我创建了一个数据源和委托,但我找不到文件所有者在 IOs5 中建立连接。我应该与什么建立联系?
故事板和加载 .xib 文件之间的一个区别是,故事板文件中每个“场景”的视图控制器都包含在该文件中。因此,假设您的视图控制器也是您的选择器的数据源和委托(这很常见),请将视图控制器连接到这些出口而不是文件的所有者代理。(对于 .xib 文件,通常在代码中实例化视图控制器并给它一个 .xib 文件,从中加载其视图,因此视图控制器是文件的所有者。)
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
if(button_Number == 1)
{
UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 280, 30)];
NSString *nameStr=[arr_countryName objectAtIndex:row];
// NSString *nameStr=[programNameArr objectForKey:@"programname"];
label.text = nameStr;
label.font = [UIFont boldSystemFontOfSize:14.0f];
label.textAlignment = UITextAlignmentLeft;
label.backgroundColor = [UIColor clearColor];
[label autorelease];
return label;
}
if (button_Number == 2)
{
UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 280, 30)];
NSString *nameStr=[arr_currencyCode objectAtIndex:row];
// NSString *nameStr=[programNameArr objectForKey:@"programname"];
label.text = nameStr;
label.font = [UIFont boldSystemFontOfSize:18.0f];
label.textAlignment = UITextAlignmentLeft;
label.backgroundColor = [UIColor clearColor];
[label autorelease];
return label;
}
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
//return (NSString*)[clientListArray objectAtIndex:row];
if(button_Number == 1)
{
return (NSString*)[arr_countryName objectAtIndex:row];
}
if (button_Number == 2)
{
return (NSString*)[arr_currencyCode objectAtIndex:row];
}
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
if(button_Number == 1)
{
return [arr_countryName count];
}
if (button_Number == 2)
{
return [arr_currencyCode count];
}
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
selectedScrollIndex = row;
// clientNameTxtFld.text = [clientListArray objectAtIndex:row];
// LBL.text = [clientListArray objectAtIndex:row];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
}
if (buttonIndex == 1 && button_Number == 1)
{
countryTxtFld.text = [arr_countryName objectAtIndex:selectedScrollIndex];
//selected_Client_ID = [clientIDArray objectAtIndex:selectedScrollIndex];
selectedScrollIndex = 0;
}
if (buttonIndex == 1 && button_Number == 2)
{
currencyTxtFld.text = [arr_currencyCode objectAtIndex:selectedScrollIndex];
//selected_Client_ID = [clientIDArray objectAtIndex:selectedScrollIndex];
selectedScrollIndex = 0;
}
}