Iphone 使用选定的单元格indexPath、UICollectionView
使用Iphone 使用选定的单元格indexPath、UICollectionView,iphone,ios6,uicollectionview,Iphone,Ios6,Uicollectionview,使用UICollectionView生成座位图。现在选择哪个单元格,得到它的indepath,但是如何使用所选单元格indepath显示为行和座位号。 下面是我尝试的方式 int ind = indexPath.item; [array addObject:[NSString stringWithFormat:@"%d", ind]]; 它给出如下输出 "<NSIndexPath 0x12135500> 2 indexes [0, 1]" “2个索引[0,1]” 如何访
UICollectionView
生成座位图。现在选择哪个单元格,得到它的indepath
,但是如何使用所选单元格indepath
显示为行和座位号。
下面是我尝试的方式
int ind = indexPath.item;
[array addObject:[NSString stringWithFormat:@"%d", ind]];
它给出如下输出
"<NSIndexPath 0x12135500> 2 indexes [0, 1]"
“2个索引[0,1]”
如何访问此对象并仅获取值0,1。
请为以上内容提供指导。一旦看了这本书,它就会帮助你
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
int ind = indexPath.item;
int section=indexPath.section;
[arr addObject:[NSString stringWithFormat:@"%d",ind]];
NSLog(@"%d,%d",section,ind);
}
编辑:
或
int n=[array indexOfObject:[NSString stringWithFormat:@“%d”,ind]];
如果([n但我想问如何从数组中删除相同的内容。请从该数组中查找对象索引,并使用objectAtIndex:method删除该对象。@user2455507[ArrtotSelselSeats removeObject:[NSString stringWithFormat:@“%d”,ind]”);这种方式不起作用。您好,我需要帮助吗?请您到chatlet我们这里来
if([arr containsObject:[NSString stringWithFormat:@"%d",ind]]){
[arr removeObject:[NSString stringWithFormat:@"%d",ind]];
}
int n=[array indexOfObject:[NSString stringWithFormat:@"%d",ind]];
if([n<[array count]]){
[array removeObjectAtIndex:n];
}