我正在使用带有两个组件的选择器.我希望如果我在所选组件的基础上在第一个组件中选择一行,它会显示相应数据的值.

当选择英格兰时,Picker表明英格兰有相应的俱乐部.我想为其他国家做同样的事情.但我没有采取哪种方法.
这是我的代码:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView
{
return 2;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component
{
if(component ==0)
{
return [Nations count];
}
else{
if(country_flag==0)
{
return [England count];
}
else if (country_flag==1)
{
return [Espana count];
}
else if (country_flag==2)
{
return [Netherlands count];
}
else if (country_flag==3)
{
return [Germany count];
}
else if (country_flag==4)
{
return [Italy count];
}
}
return 0;
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if(component ==0)
{
return [Nations objectAtIndex:row];
}
else{ …Run Code Online (Sandbox Code Playgroud) 我知道这是一个非常基本的问题,但我现在陷入困境.
我从电话簿中取出联系电话号码并将它们放在一个数组中.
然后从NSString中的数组中获取特定的一个
我试图从数字中删除空格,但实际上并没有使用以下编写的代码:
NSString *num = @"+44 123 456 7890";
num = [num stringByReplacingOccurrencesOfString:@" " withString:@"0"];
**OR**
num = [num stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
Run Code Online (Sandbox Code Playgroud)
请让我知道我需要做些什么来删除这个空间.
谢谢
编辑
NSString *num = [contactNumbers objectAtIndex:i];
num = [num stringByReplacingOccurrencesOfString:@"-" withString:@""];
num = [num stringByReplacingOccurrencesOfString:@" " withString:@""];
num = [num substringFromIndex:[num length]-10];
Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中添加特定字体.我做了所有工作,比如将字体添加到资源,plist和Copy Bundle Resources.我甚至还添加了字体类,也搜索了很多.但一切都是徒劳的,没有什么对我有用.
我正在尝试选择一个单元格UICollectionView,它被选中,但在向下滚动时,它选择底部的其他单元格并向上滚动显示其他一些要选择的单元格.
以下是我正在使用的代码 didSelectItemAtIndexPath
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *newIndex = indexPath;
cell = (CustomCollectionCell *)[collectionView cellForItemAtIndexPath:newIndex];
NSString *strId = [[masterArray valueForKey:@"id"]objectAtIndex:indexPath.row];
NSString *tempIndexRow = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
NSLog(@"%@, %@,%d ,%@, %d", strId,tempIndexRow,cell.imageView.tag,[boolArray objectAtIndex:indexPath.row],indexPath.row);
if (strId && [[boolArray objectAtIndex:indexPath.row] isEqualToString:@"False"] && cell.imageView.tag == indexPath.row) {
cell.selectedImage.image = [UIImage imageNamed:@"select.png"];
[boolArray replaceObjectAtIndex:indexPath.row withObject:@"True"];
}
else{
cell.selectedImage.image = Nil;
[boolArray replaceObjectAtIndex:indexPath.row withObject:@"False"];
}
}
Run Code Online (Sandbox Code Playgroud)
这是我第一次选择的

这是我向下滚动时得到的结果

谢谢