作为Objective-C的新手,有人可以按照@property指令给我一个概述保留,分配,复制和我缺少的任何其他内容吗?他们在做什么,为什么我要用另一个?
这是我在标题上工作的方式.
// viewDidLoad
[self.collectionView registerClass:[UICollectionViewCell class]forCellWithReuseIdentifier:@"Cell"];
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
UICollectionViewFlowLayout *layout= [[UICollectionViewFlowLayout alloc]init];
self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, 390, 300) collectionViewLayout:layout];
layout.collectionView.backgroundColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0];
[self.collectionView registerClass:[UICollectionViewCell class]
forCellWithReuseIdentifier:@"Cell"];
self.collectionView.delegate=self;
self.collectionView.dataSource=self;
layout.minimumInteritemSpacing = 15;
[layout setScrollDirection:UICollectionViewScrollDirectionVertical];
self.collectionView.collectionViewLayout = layout;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
[self.collectionView setBounces:YES];
self.collectionView.allowsMultipleSelection = YES;
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"HorizontalPickerCell"];
[self.view addSubview:self.collectionView];
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return CGSizeMake(0, kHeaderHeight);
}
return CGSizeMake(0, kHeaderHeight + …
Run Code Online (Sandbox Code Playgroud) 我想在它的点击上展开tableview单元格.有一个tableview,其中两个单元格是可扩展的,而另一些则不是.当我点击可扩展单元格时,它需要显示它下面的单元格,再次点击它应该隐藏.下面有一张图片来定义这个.
如何实现此功能,请指导以上内容.提前致谢.
我想在页面视图控制器中获取当前的视图控制器.怎么做 是否有一些代表打电话或什么.
我之前看过一些帖子,但还没有得到答案,这就是为什么我想以更有效的方式再次发帖.如何在UITableView
下面的图像中使用check-uncheck功能.
这是我想要的表格,当我点击任何单元格的按钮时,按钮图像将改变,而不是所有单元格.
我想UICollectionView
在数组中添加选定的单元格,在不同的数组中分段,表示每个部分的不同数组.问题在于这些部分是动态的.以下是我的代码.
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *seatV;
int cs;
NSString *secVal = [arrSeatSel objectAtIndex:indexPath.section];
NSArray *arrSplit = [secVal componentsSeparatedByString:@":"];
seatV = [arrSplit objectAtIndex:1];
cs = [seatV integerValue];
int v;
NSString *cnt = [NSString stringWithFormat:@"%@",[arrTot objectAtIndex:indexPath.section]];
v = [cnt intValue];
NSString *sect = [NSString stringWithFormat:@"%d", indexPath.section];
if(indexPath.item < v)
{
if([sectionInfo count] < cs)
{
itemPaths = [self.collectionView indexPathsForSelectedItems];
sectionInfo = [NSMutableArray arrayWithArray: [self.collectionView indexPathsForSelectedItems]];
[selectedItemsInfo setObject:sectionInfo forKey:sect];
cell=[self.collectionView cellForItemAtIndexPath:indexPath];
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yellow_seat.png"]];
}
else …
Run Code Online (Sandbox Code Playgroud) 我试图NSDictionary
按升序排序.我正在使用此代码:
NSDictionary *valDict = self.mGetDataDict[key][rowKey];
for (NSString *valueKey in
[[valDict allKeys] sortedArrayUsingSelector:@selector(compare:)])
{
if ([valueKey isEqualToString:@"attr"])
{
dictRow = self.mGetDataDict[key][rowKey][valueKey];
}
else {
NSString *valKey = self.mGetDataDict[key][rowKey][valueKey];
[arrSeatsStatus addObject:valKey];
}
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出:
1 = off;
10 = off;
2 = on;
3 = on;
4 = on;
5 = on;
6 = on;
7 = on;
8 = on;
9 = on;
Run Code Online (Sandbox Code Playgroud)
这是必需的输出:
1: "off",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: …
Run Code Online (Sandbox Code Playgroud) 如何检查数组中重复的时间项数.我有一个包含重复项的数组.下面是数组.
"Family:0",
"Family:0",
"Family:0",
"Gold:3",
"Gold:3"
Run Code Online (Sandbox Code Playgroud)
所以,我希望各个项目的响应值为3和2.我怎样才能做到这一点.希望我明白我的观点.如果有什么不清楚请问.
以下是我试过的代码.
int occurrences = 0;
int i=0;
for(NSString *string in arrTotRows){
occurrences += ([string isEqualToString:[arrTotRows objectAtIndex:indexPath.section]]); //certain object is @"Apple"
i++;
}
Run Code Online (Sandbox Code Playgroud) 试图在NSMutableArray中获取对象的索引.它返回一些垃圾值,而不是为什么它不返回特定项的索引.以下是我试过的代码.
NSString *type = [dictRow valueForKey:@"type"];
if([arrSeatSel indexOfObject:type])
{
NSUInteger ind = [arrSeatSel indexOfObject:type];
[arrTotRows addObject:[arrSeatSel objectAtIndex:ind]];
}
Run Code Online (Sandbox Code Playgroud)
type包含值"Gold".并且arrSeatSel包含
(
"Gold:0",
"Silver:0",
"Bronze:1"
Run Code Online (Sandbox Code Playgroud)
怎么检查.请指导.
我正在使用MHRotaryKnob来制作像动画一样的旋转拨号.我用它来制作旧的电话拨号盘.
图像.
目前它只是显示动画,当我拨打它刚刚回来的动画片.即使第一个圆圈从较低甚至没有检测到触摸,触摸也在那里工作,没有圆圈拨号.下面我发布我正在使用的代码.
- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint point = [touch locationInView:self];
if (self.interactionStyle == MHRotaryKnobInteractionStyleRotating)
{
// If the touch is too close to the center, we can't calculate a decent
// angle and the knob becomes too jumpy.
if ([self squaredDistanceToCenter:point] < MinDistanceSquared)
return NO;
// Calculate starting angle between touch and center of control.
_angle = [self angleBetweenCenterAndPoint:point];
}
else
{
_touchOrigin = point;
_angle = [self angleForValue:self.value];
}
self.highlighted = YES;
[self showHighlighedKnobImage]; …
Run Code Online (Sandbox Code Playgroud)