logo
down
shadow

How to set Separator style for UITableView


How to set Separator style for UITableView

By : Gnaniar Manimozhi
Date : November 19 2020, 03:59 PM
like below fixes the issue Potentially add a UIView as a separator of your own that has an autoresizing mask set to keep it stuck to the bottom.
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
code :
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

        self.backgroundColor = [UIColor myColour]; // do cell setup in here


        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0.0f, self.contentView.bounds.size.height - 1.0f, self.contentView.bounds.size.width, 1.0f)];
        lineView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
        lineView.backgroundColor = [UIColor myOtherColour];

        [self.contentView addSubview:lineView];
}

return self;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
      static NSString *CellIdentifier = @"Cell";

      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];

      if (!cell)
      {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: CellIdentifier];

        cell.backgroundColor = [UIColor myColour]; // do cell setup in here


        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0.0f, cell.contentView.bounds.size.height - 1.0f, cell.contentView.bounds.size.width, 1.0f)];
        lineView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
        lineView.backgroundColor = [UIColor myOtherColour];

        [cell.contentView addSubview:lineView];
      }

  // rest of your cell for row code here


Share : facebook icon twitter icon
UITableView Separator Style Question

UITableView Separator Style Question


By : user3147741
Date : March 29 2020, 07:55 AM
hop of those help? I have a tableview that is blank by default. User can add cells to it. , Maybe you are missing this?
code :
...
else
{
    self.routineTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; // or you have the previous 'None' style...
    self.routineTableView.separatorColor = [UIColor grayColor];
}
[self.tableView reloadData];
How to mimic UITableView iOS7 default line separator style?

How to mimic UITableView iOS7 default line separator style?


By : PNG 5
Date : March 29 2020, 07:55 AM
hope this fix your issue Your problem is because the view will have a width on retina of 2px if the width is set to 1px. What I would suggest is to create a subclass of UIView, let's call it CustomDivider and in -layoutSubviews you will do something like this:
code :
-(void)layoutSubviews {
    [super layoutSubviews];
    if([self.constraints count] == 0) {
        CGFloat width = self.frame.size.width;
        CGFloat height = self.frame.size.height;
        if(width == 1) {
            width = width / [UIScreen mainScreen].scale;
        }
        if (height == 0) {
            height = 1 / [UIScreen mainScreen].scale;
        }

        if(height == 1) {
            height = height / [UIScreen mainScreen].scale;
        }
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, width, height);
    }
    else {
        for(NSLayoutConstraint *constraint in self.constraints) {
            if((constraint.firstAttribute == NSLayoutAttributeWidth || constraint.firstAttribute == NSLayoutAttributeHeight) && constraint.constant == 1) {
                constraint.constant /=[UIScreen mainScreen].scale;
            }
        }
    }
}
Swift - UITableView set separator style

Swift - UITableView set separator style


By : user2968413
Date : March 29 2020, 07:55 AM
will be helpful for those in need To explain why you can't call setSeparatorStyle in Swift, I need to explain where that method comes from in Objective-C. If you search for it in the header (UITableView.h) you won't find it. The only thing declared is this:
code :
@property (nonatomic) UITableViewCellSeparatorStyle separatorStyle;
@interface SomeClass: NSObject

@property (nonatomic) id someProperty;

@end
self.tableview.separatorStyle = UITableViewCellSeparatorStyle.None
tableview.separatorStyle = UITableViewCellSeparatorStyle.None
tableview.separatorStyle = .None
UITableView Separator Style None in IB does not work

UITableView Separator Style None in IB does not work


By : Utkan Tolga Evren
Date : March 29 2020, 07:55 AM
I wish this helpful for you I tried both changing the separator style to None in IB and .none in code. In other tables that have a simple label in the row in other parts of my app, when I try to remove the separator style it works. But for some reason, in this UITableView it does not and I'm not sure why. Here is the screenshot from the simulator. , Try this :
code :
self.tableView.separatorColor = [UIColor clearColor];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
UITableView separator style missing lines

UITableView separator style missing lines


By : user1436302
Date : March 29 2020, 07:55 AM
wish of those help My code below prints the tableview array fine. However the separator lines are missing. As You can see in the photo below. This question has been asked before but I have not found a solution using any of the prior questions. , please run the app in device ,it will be fine
Related Posts Related Posts :
  • Unclear about releasing CFDictionaryRef
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org