小编alb*_*amg的帖子

UITableView在滚动时重复单元格

当我滚动我的UITableView时,出于某种原因,单元格似乎相互绘制.如果我加载我的应用程序,单元格将显示如下:

在此输入图像描述

在滚动此单元格并多次在屏幕上滚动时,它将开始显示如下:

在此输入图像描述

正如你所看到的,我似乎无法解决的问题是错误的.有任何想法吗?

编辑:cellForRowAtIndexPath

static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    NSString *vaultsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Vaults"];

    NSString *dictionaryPath = [NSString stringWithFormat:@"%@/%@",
                                vaultsPath,
                                [self.vaults objectAtIndex:indexPath.row]];
    NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:dictionaryPath];
    cell = [AHCellCreation createCellWithDictionary:dictionary Cell:cell];

    return cell;
Run Code Online (Sandbox Code Playgroud)

AHCellCreation + createCellWithDictionary:Cell:

//General cell design, same every time
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(0, 0, 320, 82);
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithHue:0 saturation:0 brightness:0.91 alpha:1] …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview

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

NSSate为NSDate为mm/dd/yyyy hh:mm:ss格式

我得到的日期字符串是8/5/2011 1:38:13 PM这种格式.我如何将其转换为NSDate

我试过了:

[dateFormatter setDateFormat:@"mm/dd/yyyy 'T' hh:mm:ss a"];
NSString *currentDate = [dateFormatter stringFromDate:currentDateString];
Run Code Online (Sandbox Code Playgroud)

它回来了nil.有什么想法吗?

date nsdate nsstring nsdateformatter ios

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

如何确定滚动UIDatePicker何时完成?

我用UIDatePicker,我想知道什么时候滚动UIDatePicker结束.谢谢.

uidatepicker ios

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

在appdelegate.m文件中找不到viewcontroller

我正在按照ios教程将Facebook纳入我的应用程序.一切都很顺利,直到我得到关于添加注销按钮的部分.我一直收到一个错误,说明在类型的对象上找不到属性"ViewController".我究竟做错了什么?这是我的appdelegate.m文件中的代码.

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Add the requests dialog button
    UIButton *requestDialogButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    requestDialogButton.frame = CGRectMake(40, 150, 200, 40);
    [requestDialogButton setTitle:@"Send Request" forState:UIControlStateNormal];
    [requestDialogButton addTarget:self 
                            action:@selector(requestDialogButtonClicked)
                  forControlEvents:UIControlEventTouchUpInside];
    [self.viewController.view addSubview:requestDialogButton];
    // ...
}
Run Code Online (Sandbox Code Playgroud)

iphone facebook ios

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

带有IF语句问题的NSNumber

我正在从服务器加载数据,但我有一个问题,我返回的值是零(0),而我不能进去,如果.请问哪里会有问题?

-(void)method1
{
     NSNumber *value = [data objectForKey:@"samount"];
     NSLog(@"number is -%@-", value); //number is -0-
     if (value == 0)
     {
          NSLog(@" OK :) ");
     }
     else 
     {
          NSLog(@"  Bad :( ");
     }
}
Run Code Online (Sandbox Code Playgroud)

objective-c nsnumber ios

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

xcode如何定义视图的高度和宽度

大家好我是法国人因为我的英语而烦恼我这里是我的问题:我们如何定义视图的高度和宽度.这里它的名字是flakeView.这是代码:

UIImageView* flakeView = [[[UIImageView alloc] initWithImage:flakeImage] autorelease];

// use the random() function to randomize up our flake attributes
int startY = round(random() % 320);

// set the flake start position
flakeView.center = CGPointMake(490, startY);
flakeView.alpha = 1;

// put the flake in our main view
[self.view addSubview:flakeView];

[UIView animateWithDuration:7
                 animations:^{
                     // set the postion where flake will move to
                     flakeView.center = viewToRotate.center;
                 }];
Run Code Online (Sandbox Code Playgroud)

iphone height width uiimageview

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

发送到实例的无效选择器 - objectForKey:

运行我的代码时出错.罪魁祸首是我从下面的plist访问一个字符串:

    NSString *sImageFile = [dictionary objectForKey:@"answerCorrect"];
    NSLog(@"%@",sImageFile);
Run Code Online (Sandbox Code Playgroud)

我在这里显示的cocos2d Init中有这个:

-(id) init
{
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value
    if( (self=[super init])) {

        NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
        NSString *ctlLang = [sud valueForKey:@"ctlLang"];
        NSNumber *questionState = [sud valueForKey:@"questionState"];
        NSNumber *scoreState = [sud valueForKey:@"scoreState"];
        gameArray = (NSMutableArray *)[sud valueForKey:@"gameArray"];
        for (NSString *element in gameArray) {
            NSLog(@"\nQL gameArray value=%d\n", [element intValue]);
        }
        NSString *path = [[NSBundle mainBundle] bundlePath];
        NSString *finalPath = [path stringByAppendingPathComponent:ctlLang]; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsdictionary nsstring ios

0
推荐指数
1
解决办法
2036
查看次数