小编S-T*_*G-A的帖子

UITableView自定义节标题,重复的问题

我无法设置自定义UITableView节标题的动画.
目标是创建可折叠部分.
当我第一次按照预期动画时点击自定义标题,然而每次之后它会在原始位置留下副本并为另一个创建动画.

图片示例:

替代文字http://img35.imageshack.us/img35/4018/screenshot2010022722565.png 替代文字http://img291.imageshack.us/img291/8287/screenshot2010022723035.png
我的自定义标题:

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
       UIView* customView = [[[UIView alloc]initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)]autorelease];
       customView.backgroundColor = [UIColor lightGrayColor];

       UILabel * headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
            headerLabel.backgroundColor = [UIColor clearColor];
            headerLabel.opaque = NO;
            headerLabel.textColor = [UIColor darkGrayColor];
            headerLabel.font = [UIFont boldSystemFontOfSize:16];
            headerLabel.frame = CGRectMake(10, 7, 260.0, 44.0);
            headerLabel.textAlignment = UITextAlignmentCenter;
            NSDictionary *dictionary = [self.data objectAtIndex:section];
            headerLabel.text = [dictionary objectForKey:@"Title"];

            [customView addSubview:headerLabel];


            // add button to right corner of section
        UIButton* headerButton = …
Run Code Online (Sandbox Code Playgroud)

iphone animation uitableview sectionheader

6
推荐指数
1
解决办法
7958
查看次数

基于int创建多个编号变量

如何NSDictionary使用数组计数创建多个变量?

这基本上就是我提出的,但我不确定如何使用Objective-C语法来完成这项工作.doesntContainAnother是一个NSArray.我希望字典的名称使用当前值loopInt.

int *loopInt = 0;
while (doesntContainAnother.count <= loopInt) {

    NSMutableDictionary *[NSString stringWithFormat:@"loopDictionary%i", loopInt] = [[[NSMutableDictionary alloc] init] autorelease];
    [NSString stringWithFormat:@"loopDictionary%i", loopInt] = [NSDictionary dictionaryWithObject:[array1 objectAtIndex:loopInt] 
                                                 forKey:[array2 objectAtIndex:loopInt]];
    loopInt = loopInt + 1;
}
Run Code Online (Sandbox Code Playgroud)

string variables objective-c variable-names

5
推荐指数
0
解决办法
1204
查看次数

带有if else的循环中的多个语句

编辑:更新代码以更好地反映我的问题

此代码返回9个字符串给badDestination1

NSMutableArray* goodDestination1 = [NSMutableArray array];
NSMutableArray* badDestination1 = [NSMutableArray array];
NSMutableArray* badDestination2 = [NSMutableArray array];

for (NSString* item in sourceArray)
{
    if ([item rangeOfString:@"<b>"].location != NSNotFound)

        [goodDestination1 addObject:item];

    else {
        [badDestination1 addObject:item];
        //[badDestination2 addObject:@"Title"];
    }
}
Run Code Online (Sandbox Code Playgroud)

此代码向badDestination2返回1个值

for (NSString* item in sourceArray)
    {
        if ([item rangeOfString:@"<b>"].location != NSNotFound)

            [goodDestination1 addObject:item];

        else {
            //[badDestination1 addObject:item];
            [badDestination2 addObject:@"String"];
        }
    }
Run Code Online (Sandbox Code Playgroud)

有谁知道发生了什么?好像"String"可能会在阵列上的相同位置被重写?

objective-c

3
推荐指数
1
解决办法
204
查看次数