小编use*_*155的帖子

UITableView自定义单元格滚动后消失的内容

我已经看过很多次这里被问过,但没有一个解决方案适合我.这是我的代码片段:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellClassName = @"DemoTableViewCell_sched";
    DemoTableViewCell_sched *cell = [tableView dequeueReusableCellWithIdentifier:CellClassName];

    if (cell == nil)
    {
        NSArray *topLevelItems = [cellLoader instantiateWithOwner:self options:nil];
        cell = [topLevelItems objectAtIndex:0];
    }
    cell.fooData = [self.bugs objectAtIndex:indexPath.row];    
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

然后我进来了 ViewDidLoad

    cellLoader = [UINib nibWithNibName:@"DemoTableViewCell_sched" bundle:[NSBundle mainBundle]];
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitableview

6
推荐指数
4
解决办法
6692
查看次数

stringByReplacingCharactersInRange减少NSString长度

我以某种方式错误地使用stringByReplacingCharactersInRange,但我无法理解如何.我的目标是将一个角色替换为另一个角色NSString.我做了很多次,但经过两次更换后,它从NSString的末尾开始切割,我不想这样做.这是我的代码.

    NSRange firstCharRange = NSMakeRange(mi, mi); // mi is an int, indicating the index of the replaced char

    myword = [myword stringByReplacingCharactersInRange:firstCharRange withString:bb.titleLabel.text]; // myword is the string
Run Code Online (Sandbox Code Playgroud)

最初myword是@"RRRRRRRR",在替换第一个字符串后就成了

eRRRRRRR
Run Code Online (Sandbox Code Playgroud)

然后

egRRRRRR
Run Code Online (Sandbox Code Playgroud)

然后

eghRRRR // why did cut off the last character?
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c nsstring ipad

-2
推荐指数
1
解决办法
2575
查看次数

标签 统计

iphone ×2

xcode ×2

ipad ×1

nsstring ×1

objective-c ×1

uitableview ×1