Uitableviewcells with Uibutton Overlaps While Scrolling

UITableViewCells with UIButton overlaps while scrolling

just replace the line

  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]

is now

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];

(or) //use this in cell for rowatindexpath

for(UIView *view in cell.contentView.subviews){
if ([view isKindOfClass:[UIView class]]) {
[view removeFromSuperview];
}
}

UIButton and TextLabel overlapping in UITableViewCell

Sorry but your code is completely wrong..you are using an incorrect way and also you are adding a button each time.

The tableViewCell are REUSED so you have to add buttons and other UI elements just when you INIT the cell and not each time, or your app will finish in memory warning, crash, not fluid etc.

The correct way to do what you want to do is create your CustomTableViewCell subclassing the class UITableViewCell and add your labels and buttons. It is really simple:

1) Create a new file CustomSearchCell object that extends UITableViewCell:

CustomSearchCell.h

#import <UIKit/UIKit.h>

@interface CustomSearchCell : UITableViewCell

@property (strong, nonatomic) UIButton *button;
@property (strong, nonatomic) UILabel *lblDetails;

@end

CustomSearchCell.m

#import "CustomSearchCell.h"

@implementation CustomSearchCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
_lblDetails = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 200, 45)];
[_lblDetails setFont:[UIFont systemFontOfSize:20.0]];
[_lblDetails setTextColor:[UIColor blackColor]];

_button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, self.frame.size.height)];

[self.contentView addSubview: _lblDetails];
[self.contentView addSubview: _button];
}
return self;
}

@end

2) In your view controller:

#import "CustomSearchCell.h"

and:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
static NSString *CellIdentifier = @"ListCellIdentifier";
CustomSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[CustomSearchCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

//Settings

return cell;
}

Another your problem is when you press the button. You will receive the sender but the tableViewCell will can be used for a different indexPath when you intercept the touch..be careful..the correct way is another..you need to save in some way the actual indexPath when you press the button...

Why UITableView cell overlap while scrolling?

Your code is very wrong... As I can see, you're creating your cell through interface builder. In that case, you create your custom UITableViewCell class for it, which will have IBOutlets to your UILabels and UIImageViews (and other UI elements you'd like). This will make sure your UI elements get created for you and you don't have to alloc-init and addSubview in your cellForRow method.

It would take fairly long to explain everything here, so you could take a look at this tutorial, it explains how to create custom UITableViewCells better then I could. Mainly Option 2: Prototype Cells is what you need.

Swift- Buttons on ScrollView in CustomCell overlapping each other

What you are doing is adding the button subviews to a cell that was already configured. You will need to remove existing buttons from the cell after you dequeueReusableCellWithReuseIdentifier:forIndexPath and re-create them again.

Custom cell in UITableView make images overlap on scroll

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"myCustomCell";
OrderCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];

if(cell == nil){
[tableView registerNib:[UINib nibWithNibName:@"myCustomCell" bundle:nil] forCellReuseIdentifier:CellIdentifier];
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
}
...
cell.Title.text = @"some value";
...
if(...){
cell.image1.hidden = YES;
cell.image2.hidden = NO;
}
else{
cell.image1.hidden = NO;
cell.image2.hidden = YES;
}
...

UITableViewCell content overlaps delete button when in editing mode in iOS7

try using the accessoryView and editingAccessoryView properties of your UITableViewCell, instead of adding the view yourself.

If you want the same indicator displayed in both editing and none-editing mode, try setting both view properties to point at the same view in your uiTableViewCell like:

self.accessoryView = self.imgPushEnabled;
self.editingAccessoryView = self.imgPushEnabled;

There seems to be a glitch in the table editing animation in IOS7, giving an overlap of the delete button and the accessoryView when switching back to non-editing state. This seems to happen when the accesoryView is specified and the editingAccessoryView is nil.

A workaround for this glitch, seems to be specifying an invisible editingAccessoryView like:

self.editingAccessoryView =[[UIView alloc] init];
self.editingAccessoryView.backgroundColor = [UIColor clearColor];

How to fix a Table view cell title text overlap each when it is scrolled

Your cell height was not matching with the subviews contentsize you are adding in cellForRowAtIndexPath method.

Also you should use unique Identifier for each row. Otherwise the already created cell with the same Identifier "landscape-cell" was re-used and not created again .
Use the Identifier something like

[NSString stringWithformat: "cell_%d",indexpath.row];

Hope you achieve the target.

iOS 7.1 UitableviewCell content overlaps with ones below

The issue has to do with the height of your cell. It isn't going to dynamically adjust that for you.

You'll probably notice that as you scroll and the view above goes out of view the overlapping text will disappear with it.

If you are wanting your text to clip at a certain height, then you need to set the number of lines, rather than setting it to 0 since that will let it continue forever.

The lineBreakMode won't take effect since it isn't stopped.

Optionally you could try to set clipping on the contentView to make sure all subviews stay inside.

Depending on the end result you want, you could do dynamic heights and change based on the content. There are a bunch of SO questions related to doing this.

Update - clipping the contentView

I'd have to try it out myself, but in lieu of that, here are a couple links related to clipping the contentView:

  • stop the clipping of contentView - you'd actually want to do the opposite.
  • adding subview - looks similar to what you are trying to do.

Looks like this works:

cell.clipsToBounds = YES;

Custom UItableViewCell label is overlapping

This could simply be a minor mistake. Try using a different tag value, or verify the values being used in the prototype cell.

UIButton with UIImages in a UITableViewCell - Overlapping etc

Ended up fixing the solution by doing the following simple code:

NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview]superview]];

I used the UIButton sender to get the cell that it was within. I also pulled out all the modifications of the .tag's and kept them at the same number.



Related Topics



Leave a reply



Submit