0

そのため、ゲームのメイン メニューに戻ったときに、非常に異常なメッセージが表示されることがあります。写真からわかるように、UIView テーブルの外側にセルを複製しました。最初は、メモリの問題に基づくグラフィックスの破損だと思っていました。その後、それらと対話できることを発見しました。それらは有効なセルです...ゴースト画像ではなく、コードに応答します。それで、少し検索して、ただし、テーブルが編集モードか何かで動かなくなったので、可能な限り setediting:NO を呼び出します。そして、それは今でも私を悩ませています。

何がこれを引き起こしているのか、誰にも最初の考えがありますか? 常に発生するわけではありませんが、発生するように見えるだけです...その上にある別のビューからこの画面に戻ったときに発生する場合. また、一貫して複製することもできないため、修正して原因を特定することは困難です。

私が何かをしているかもしれないし、私が言及していないことをしていないかもしれないことを心に留めておいてください。

テーブル セルの不具合 編集:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger) tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
    return [[[CurrentGamesInfo sharedCurrentGamesInfo] _currentGames] count];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    _indexPath = indexPath;
     NSLog(@"%i",_indexPath.row);
    [_indexPath retain];

    [[CurrentGamesInfo sharedCurrentGamesInfo] SetCurrentGameWithIndex:[_indexPath row]];

    UIView *tempView = [[[tableView cellForRowAtIndexPath:indexPath] contentView] viewWithTag:200];

    if([[[(UIButton*)[tempView viewWithTag:CELL_BUTTONTEXT_ID] titleLabel] text] isEqualToString:@"Waiting"])
    {
        return;
    }

    if( ![[CurrentGamesInfo sharedCurrentGamesInfo] _selectedGame].isGameReady )
    {
        [_PopUp OptionsMessage:@"Game Not Ready" withTitle:@"Hold Your Horsies" hideBackButton:YES];
        return;
    }

    NSString *gameID = [[[CurrentGamesInfo sharedCurrentGamesInfo] _selectedGame] GetGameID];

    NSLog(@"%i",[[[CurrentGamesInfo sharedCurrentGamesInfo] _selectedGame] GetTurnNumber].intValue);

    NSData *pngData = [NSData dataWithContentsOfFile:[AppDelegate applicationDocumentDirectory:gameID]];

    UIImage *image = [UIImage imageWithData:pngData];

    PhotoImage *photoImg = [[PhotoImage alloc]init];
    [photoImg set_imageToSend:image];
    [[[CurrentGamesInfo sharedCurrentGamesInfo] _selectedGame] SetImageToSend:photoImg];
    [photoImg release];

    UIImageView * imgView = (UIImageView*)[[[[tableView cellForRowAtIndexPath:indexPath] contentView]viewWithTag:300] viewWithTag:301];
    [[[CurrentGamesInfo sharedCurrentGamesInfo]_selectedGame]setOpponentProfilePic:imgView.image];

    [self TempCurrentGameFunction];
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;
} 

警告: 大量の関数が着信中です

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;

    GameInfo *gameThisRow = [[[CurrentGamesInfo sharedCurrentGamesInfo]_currentGames] objectAtIndex:indexPath.row];

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"] autorelease];

    cell.selectionStyle = UITableViewCellSelectionStyleBlue;

    NSLog(@"row : %i",indexPath.row);
    NSLog(@"current game count : %i",[[[CurrentGamesInfo sharedCurrentGamesInfo] _currentGames]count]);

    NSString *gameType = @"";

    UIButton *gameStatusButton = [[UIButton alloc]initWithFrame:CGRectMake(100, -5, 90, 70)];

    Boolean isYourTurn = [[gameThisRow GetPlayerRole] intValue] ? YES : NO;

    NSString *gameStateString = @"Your Move";
    [cell setUserInteractionEnabled:YES];

    [cell setTag:ACTIVE_GAME_CELL];

    if(!isYourTurn)
    {
        //_activeGameCount--;
        gameStateString = @"Waiting";
        [cell setUserInteractionEnabled:NO];
        [cell setTag:INACTIVE_GAME_CELL];
    }

    [gameStatusButton setTitle:gameStateString forState:UIControlStateNormal];
    [[gameStatusButton titleLabel] setFont:[UIFont fontWithName:@"Fredoka One" size:10]];
    [gameStatusButton setTag:CELL_BUTTONTEXT_ID];

    if( indexPath.row  < [[[CurrentGamesInfo sharedCurrentGamesInfo] _currentGames]count])
    {
        switch ([gameThisRow gameType]) 
        {
            case 0:
                gameType = @"Open Game";
                [gameStatusButton setBackgroundImage:[UIImage imageNamed:@"buttonB_blue.png"] forState:UIControlStateNormal];
                break;

            case 1:
            {
                gameType = @"Challenge Game";
                [gameStatusButton setBackgroundImage:[UIImage imageNamed:@"buttonB_orange.png"] forState:UIControlStateNormal];

            }

                break;

            case 2:
            {
                gameType = @"Battle Game";
                [gameStatusButton setBackgroundImage:[UIImage imageNamed:@"buttonB_pink.png"] forState:UIControlStateNormal];
            }
                break;

            default:
                break;
        }
    }

    NSLog(@"%@",[[gameThisRow GetFaceBookData]objectForKey:@"name"]);

    NSString *name = [[gameThisRow GetFaceBookData]objectForKey:@"name"];

    UIView *labelView = [[UIView alloc] initWithFrame:CGRectMake(80, 10, 100, 50)];
    [labelView setTag:200];

    [labelView addSubview:gameStatusButton];
    [gameStatusButton release];

    [labelView setBackgroundColor:[UIColor clearColor]];

    UILabel *labelName = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, 100, 20)];

    NSString *text = name;

    NSArray *nameArray = [text componentsSeparatedByString:@" "];

    NSString *nameWithInitials;

    nameWithInitials = [NSString stringWithFormat:@"%@",[nameArray objectAtIndex:0]];

    for( int i = 1; i < nameArray.count; ++i )
    {
        NSString *temp = [nameArray objectAtIndex:i];
        nameWithInitials = [nameWithInitials stringByAppendingFormat:@" %C.",[temp characterAtIndex:0]];
    }

    text = nameWithInitials;

    int maxSize = 20;
    int minSize = 8;
    UIFont *font = [UIFont fontWithName:@"Fredoka One"size:maxSize];

    /* Time to calculate the needed font size.
     This for loop starts at the largest font size, and decreases by two point sizes (i=i-2)
     Until it either hits a size that will fit or hits the minimum size we want to allow (i > 10) */
    for(int i = maxSize; i > minSize; i=i-2)
    {
        // Set the new font size.
        font = [font fontWithSize:i];
        // You can log the size you're trying: NSLog(@"Trying size: %u", i);

        /* This step is important: We make a constraint box 
         using only the fixed WIDTH of the UILabel. The height will
         be checked later. */ 
        CGSize constraintSize = CGSizeMake([labelName frame].size.width, MAXFLOAT);

        // This step checks how tall the label would be with the desired font.
        CGSize labelSize = [text sizeWithFont:font constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];

        /* Here is where you use the height requirement!
         Set the value in the if statement to the height of your UILabel
         If the label fits into your required height, it will break the loop
         and use that font size. */
        if(labelSize.height <= [labelName bounds].size.height)
            break;
    }
    // You can see what size the function is using by outputting: NSLog(@"Best size is: %u", i);

    // Set the UILabel's font to the newly adjusted font.
    [labelName setFont:font];

    // Put the text into the UILabel outlet variable.
    [labelName setText:text];

    [labelName setTextColor:[UIColor grayColor]];
    [labelName setBackgroundColor:[UIColor clearColor]];
    [labelName setTextAlignment:UITextAlignmentCenter];
    [labelView addSubview:labelName];
    [labelName release];

    UILabel *labelSubtitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 100, 50)];

    [labelSubtitle setText:gameType];
    [labelSubtitle setFont:[UIFont fontWithName:@"Fredoka One" size:10]];
    [labelSubtitle setTextColor:[UIColor grayColor]];
    [labelSubtitle setBackgroundColor:[UIColor clearColor]];
    [labelSubtitle setTextAlignment:UITextAlignmentCenter];

    [labelView addSubview:labelSubtitle];
    [labelSubtitle release];

    [[cell contentView] addSubview:labelView];

    NSString *path = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?width=200&height=200",[[gameThisRow GetFaceBookData]objectForKey:@"id"] ]; 

    UIImageView *pictureImage = [[UIImageView alloc] init];

    [pictureImage setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:@"Icon-Small.png"]success:^(UIImage *image)
     {
         pictureImage.image = [image imageScaledToSize:CGSizeMake(100, 100)];

     } failure:^(NSError *error) 
     {
         [pictureImage setImage:[[UIImage imageNamed:@"Icon-Small.png" ]imageScaledToSize:CGSizeMake(50, 50)]];
         NSLog(@"%@",[error localizedDescription]);
     }];

    NSLog(@"%@",[pictureImage image]);

    pictureImage.layer.masksToBounds = YES;

    [pictureImage setFrame:CGRectMake(pictureImage.frame.origin.x+20, 37 - 25, 50, 50)];

    UIImageView *pictureFrameView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"profile_frame.png"]];
    CGRect temp = pictureImage.frame;
    //hand & hard coded, i feel so ashamed and sullied
    temp.origin.x -= 12;
    temp.origin.y -= 9;
    temp.size.width = 70;
    temp.size.height = 73;
    [pictureFrameView setFrame:temp];

    UIView *pictureView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];

    [pictureView addSubview:pictureFrameView];
    [pictureView addSubview:pictureImage];
    [pictureImage setTag:301];
    [pictureFrameView release];
    [pictureImage release];

    [[cell contentView] addSubview:pictureView];
    [pictureView setTag:300];
    [pictureView release];



    //custom stuff start
    UIImage *rowBackground;
    //UIImage *selectionBackground;
    NSInteger sectionRows = [tableView numberOfRowsInSection:[indexPath section]];
    NSInteger row = [indexPath row];
    if (row == 0 && row == sectionRows - 1)
    {
        rowBackground = [UIImage imageNamed:@"table_bottom.png"];
        //selectionBackground = [UIImage imageNamed:@"topAndBottomRowSelected.png"];
    }
    else if (row == 0)
    {
        rowBackground = [UIImage imageNamed:@"table_top.png"];
        //selectionBackground = [UIImage imageNamed:@"topRowSelected.png"];
    }
    else if (row == sectionRows - 1)
    {
        rowBackground = [UIImage imageNamed:@"table_bottom.png"];
        //selectionBackground = [UIImage imageNamed:@"bottomRowSelected.png"];
    }
    else
    {
        rowBackground = [UIImage imageNamed:@"table_mid.png"];
        //selectionBackground = [UIImage imageNamed:@"middleRowSelected.png"];
    }
    UIImageView *imageView = [[UIImageView alloc] initWithImage:rowBackground];
    [cell setBackgroundView:imageView];
    [imageView release];
    //((UIImageView *)cell.selectedBackgroundView).image = selectionBackground;
    //custom stuff end

    __block CGRect newPos = inviteFriendsParentView.frame;
    CGRect tempCurrentGameSubMenuFrame = currentGameSubMenu.frame;
    tempCurrentGameSubMenuFrame.size.height = [friendsTable rowHeight] * [friendsTable numberOfRowsInSection:0] + 10;
    currentGameSubMenu.frame = tempCurrentGameSubMenuFrame;
    float bottomofFrameYPos =  currentGameSubMenu.frame.size.height;
    newPos.origin.y += bottomofFrameYPos;

    return cell;
}
4

0 に答える 0