Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i use this in a UITableView? #2

Open
ismaiI1 opened this issue Mar 16, 2015 · 2 comments
Open

how can i use this in a UITableView? #2

ismaiI1 opened this issue Mar 16, 2015 · 2 comments

Comments

@ismaiI1
Copy link

ismaiI1 commented Mar 16, 2015

Hi, I want to use this class in an UITableView. I am creating JNJProgressButton programmatically and adding my UITableViewCell. But when i touch 1st button, 1st progress is shown but 8th progress is shown too. when I scroll down i show a lot of progress view. What i am doing wrong?

@jnjosh
Copy link
Owner

jnjosh commented Mar 16, 2015

Without seeing what you are doing it's hard to say. I'd suspect that this is something to do with your cells being reused and not setting up the button when the cell is being displayed. Also, are you using the block-based or delegate-based API? If you are using the delegate and don't have a way to track which button is being sent to you, you might be actually updating the wrong button.

@ismaiI1
Copy link
Author

ismaiI1 commented Mar 16, 2015

sorry, That's my code. I want to add 2 UILabel and 1 JNJProgressButton. And when i click JNJButton i will start a file download.

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

        static NSString *CellIdentifier = @"ImageInTheHouse";
        UILabel *mainLabel, *secondLabel;
        JNJProgressButton *progressButton;

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            cell.accessoryType = UITableViewCellAccessoryNone;
            mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(35.0, 0.0, 220.0, 15.0)];
            mainLabel.tag = MAINLABEL_TAG;
            mainLabel.font = [UIFont systemFontOfSize:14.0];
            mainLabel.textAlignment = NSTextAlignmentLeft;
            mainLabel.textColor = [UIColor blackColor];
            mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
            [cell.contentView addSubview:mainLabel];

            secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(35.0, 20.0, 220.0, 25.0)];
            secondLabel.tag = SECONDLABEL_TAG;
            secondLabel.font = [UIFont systemFontOfSize:12.0];
            secondLabel.textAlignment = NSTextAlignmentLeft;
           secondLabel.textColor = [UIColor darkGrayColor];
            secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
            [cell.contentView addSubview:secondLabel];

            progressButton = [[JNJProgressButton alloc ]initWithFrame:CGRectMake(200.0, (cell.frame.size.height-28)/2, 40, 28)];
            progressButton.tag = BUTTON_TAG;
            [cell.contentView addSubview:progressButton];
        } else {

            mainLabel = (UILabel *)[cell.contentView viewWithTag:MAINLABEL_TAG];
            secondLabel = (UILabel *)[cell.contentView viewWithTag:SECONDLABEL_TAG];
            progressButton = (JNJProgressButton *)[cell.contentView viewWithTag:BUTTON_TAG];

        }

NSArray *x=[DataArr objectAtIndex:indexPath.row];
mainLabel.text = [x objectAtIndex:1];
secondLabel.text = [x objectAtIndex:2];
progressButton.tintColor = [UIColor blueColor];
progressButton.startButtonImage = [UIImage imageNamed:@"56-cloud"];
progressButton.endButtonImage = [UIImage imageNamed:@"06-magnify"];
cell.tag = indexPath.row;
return cell;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants