logo
down
shadow

Preferred approach for changing UITableViewCell content based on cell width


Preferred approach for changing UITableViewCell content based on cell width

By : tobias.lilja
Date : November 22 2020, 10:38 AM
Any of those help Simply adding this logic to layoutSubviews should do the trick. It's called each time the auto layout engine does its thing.
code :
-(void)layoutSubviews {
    self.someLabel.text = CGRectGetWidth(self.bounds) < 321 ? @"Concise" : @"Much longer blurb";
    [super layoutSubviews];
}


Share : facebook icon twitter icon
Adjusting the width of a UILabel in UITableViewCell based on the width of a second UIView in the Cell

Adjusting the width of a UILabel in UITableViewCell based on the width of a second UIView in the Cell


By : mappo
Date : March 29 2020, 07:55 AM
help you fix your problem Nothing easier than that: every UITableViewCell is also a UIView, which has a method designed for just that: layoutSubviews, which is called whenever the view (here: cell) needs a re-layout. This is where you lay out the content.
Changing UITableViewCell width to fit a UIImageView outside of the cell

Changing UITableViewCell width to fit a UIImageView outside of the cell


By : Jacki
Date : March 29 2020, 07:55 AM
Does that help I managed to produce what I wanted using the follow, this is proberly not the best way or cleanest way but as no one from StackOverFlow gave any better suggestions I thought I better answer this.
I subclassed the first 3 UITableViewCells and set a frame size to take into account the size of my image.
code :
- (void)setFrame:(CGRect)frame {
float cellWidth = (frame.size.width - 345);
frame.size.width = cellWidth;

[super setFrame:frame];
//Create and position the image view
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((firstCell.frame.size.width), (firstCell.frame.origin.y + 70), 300, 137)];

// Add border and round corners of image view to make style look a little like tableviewcells
[imageView.layer setBorderColor:[UIColor colorWithWhite:0 alpha:0.5].CGColor];
[imageView.layer setBorderWidth:2.0];
[imageView.layer setCornerRadius:5.0];
[imageView setClipsToBounds:YES];

//Set the image in the image view
UIImage *image = [UIImage imageNamed:@"defaultPicture.png"];
imageView.image = image;

//Set resizing of image view for when view is rotated
imageView.contentMode = UIViewContentModeRedraw;
imageView.autoresizingMask = UIViewContentModeScaleAspectFit;

//Add tap gesture for imageview to initiate taking picture.
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *imageViewTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(takePicture:)];
[imageView addGestureRecognizer:imageViewTap];

//Add image view to view
[self.view addSubview:imageView];
Make content of a table cell bigger than the cell without changing the cell's width

Make content of a table cell bigger than the cell without changing the cell's width


By : QIN Reynold
Date : March 29 2020, 07:55 AM
This might help you As the title might be confusing I'm gonna explain what I mean using some pictures. , How about applying max-width for the tds so that they don't expand?
code :
table {
    border-spacing: 0px;
    border-collapse: collapse;
}
table td {
    max-width: 100px; /* applied max-widht here */
    border: 1px solid red;
}
table input {
    width: 100%;
    box-sizing: border-box;
}
#dd {
    width: 300px;
}
<table>
    <tr>
        <td>
            <input type="text" />
        </td>
    </tr>
    <tr>
        <td>
            <select id="dd">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
            </select>
        </td>
    </tr>
</table>
Content of cell should take all row without changing columns width

Content of cell should take all row without changing columns width


By : MeravM
Date : March 29 2020, 07:55 AM
Hope that helps I want to have a little not standard table. This is how it should look: , use colspan
code :
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <table class="table">
   <thead>
      <tr>
         <th>First Name</th>
         <th>Last Name</th>
         <th>Username</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Mark
            <div>Age: 18</div>
            <div>Income: 85</div>
             
        </td>
         <td>Otto</td>
         <td>@mdo</td>
      </tr>
     <tr>
       <td colspan="3"><div>
               <span>Note:</span>
               <span>A big text here, A big text here, A big text here, A big text here, A big text here</span>
             </div>
       </td>
     </tr>
      <tr>
         <td>Jacob</td>
         <td>Thornton</td>
         <td>@fat</td>
      </tr>
      <tr>
         <td>Larry</td>
         <td>the Bird</td>
         <td>@twitter</td>
      </tr>
   </tbody>
</table>
  
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

</body>
</html>
.tr-holder>td {
  padding-bottom: 35px !important;
}
.full-width {
  position: absolute;
  left: 0;
  width: 100%;
  padding: 0 9px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <table class="table">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr class="tr-holder"> <!-- class added -->
      <td>Mark
        <div>Age: 18</div>
        <div>Income: 85</div>
        <div class="full-width"> <!-- class added -->
          <span>Note:</span>
          <span>A big text here, A big text here, A big text here, A big text here, A big text here</span>
        </div>
      </td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>

    </tr>
    <tr>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

  
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

</body>
</html>
How to create UITableViewCell with dynamic cell height based on its content

How to create UITableViewCell with dynamic cell height based on its content


By : user5449910
Date : March 29 2020, 07:55 AM
This might help you For TextView, it must not be scrollable.
Also, Your constraints are should be provided in such a way that, TableViewCell should get height automatically(there must be vertical spacing constraints between each component, Height of the each component must be there(it may be explicit of implicit height, but it must need to have height)).
Related Posts Related Posts :
  • 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
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org