uitableview

Adjust UITableView height dynamically

邮差的信 提交于 2020-01-14 04:43:08
问题 How can I adjust the UITableView height dynamically? Let's say I have 3 rows and each row has a height of 65. When a new row is added to the UITableView i want it to adjust it's height dynamically to fit the new row. And vice versa when a row is deleted to shrink. 回答1: Edit : Misread The thing depends on the (height of table cell row * number of rows in table) as the tableview.frame.size.height. Well I would suggest something like this.. -(void)correctHeight { //Note : if all cells are having

showing action sheet in the custom cell in Swift

馋奶兔 提交于 2020-01-14 03:46:10
问题 I have a custom cell that contains a button inside it, I want to show an action sheet when the button is pressed, but as u know , UITableViewCell is doesn't have the method "presentViewController", so what should I do? 回答1: In your custom cell's swift file, write a protocol to be conformed by your viewContoller, // your custom cell's swift file protocol CustomCellDelegate { func showActionSheet() } class CustomTableViewCell : UITableViewCell { var delegate: CustomCellDelegate? // This is the

Disable Cell Swipe Action

不想你离开。 提交于 2020-01-14 03:44:07
问题 So I have an app(written in Swift) that allows a user to search for golf courses in a searchController. They can then select that course and then that selected course goes into a tableView. I'm using the same view controller for both the search controller and the list of the selected courses. The issue I'm having is I want the user to have the ability to swipe to delete their selected courses but NOT the courses that populate search controller when it is active. The swipe to delete action is

Get text from UITextField on a TableViewCell

半城伤御伤魂 提交于 2020-01-14 03:00:10
问题 I have a UITableViewController with prototype cells containing UITextFields. To configure these custome cells, I've created a UITableViewCell subclass. I've conected the textField to the cell subclass via an outlet (nonatomic, weak) . On this subclass I've created a protocol for which the UITableViewController is its delegate so that everytime something changes in these textFields, the TableViewController knows about it. Basically I wanted this to save the values on the NSUserDefaults Besides

Remove the UITableView Section Border and Background Color with Static Cells ?

六月ゝ 毕业季﹏ 提交于 2020-01-13 20:33:07
问题 I am using UITableView with static cells to make a small form. I added number of sections in the UITableView but now I have to remove the background color and the border of the section that displays the Login and Forgot Password button. Check out the screenshot below. Question 1 How can I remove the background color and the border? Question 2 Also is there anyway to change the background color of the view. This view inherits from UITableViewController . I believe that I need to change the

Image added to UITableViewCell appears in wrong rows when scrolling

橙三吉。 提交于 2020-01-13 19:36:16
问题 I'm adding an image to a table view row (actually, I seem to be adding it to the row's cell) when selecting it (and removing when selecting it again). The table view consists of prototype cells. This works but when I scroll around and get back to the row I had previously selected, the image would be in another row. Also, the image appears in other rows as well. My guess is this happens because the cells are re-used when scrolling. Here's the code of a little sample project: import UIKit class

Auto layout of custom programmatic UITableViewCell fails upon scrolling

徘徊边缘 提交于 2020-01-13 18:30:25
问题 I'm trying to use the new auto layout capability of iOS 6 on a custom UITableViewCell which has been implemented programmatically. I added the addConstraint calls, and it works properly at first-- until I scroll. When I come back to the cell after scrolling the layout is trashed. By trashed I mean the margins between fields are all wrong (too large, well beyond the size of the cell). I'm speculating this has something to do with the dequeueReusableCellWithIdentifier method leaving me with a

How to make UITableView not change imageView's frame, or resize the image to fill the frame size?

巧了我就是萌 提交于 2020-01-13 16:25:12
问题 In tableView:cellForRowAtIndexPath , I am setting imageView.image to a 1x1, or 60x60 placeholder image, while the cell's height is 300. I also set imageView.frame to (0,0, 300, 300) . Then I call a method downloadImageFromURL:andSetIntoCell , which immediately add a UIActivityIndicatorView and set the frame to (0,0, 300, 300) (the download is done asynchronously in a thread, and the method won't wait for the download but just return immediately). However, after tableView:cellForRowAtIndexPath

How to make UITableView not change imageView's frame, or resize the image to fill the frame size?

佐手、 提交于 2020-01-13 16:23:30
问题 In tableView:cellForRowAtIndexPath , I am setting imageView.image to a 1x1, or 60x60 placeholder image, while the cell's height is 300. I also set imageView.frame to (0,0, 300, 300) . Then I call a method downloadImageFromURL:andSetIntoCell , which immediately add a UIActivityIndicatorView and set the frame to (0,0, 300, 300) (the download is done asynchronously in a thread, and the method won't wait for the download but just return immediately). However, after tableView:cellForRowAtIndexPath

Set matching font sizes on UILabels in a UITableViewCell when one Label adjustFontSizeToFitWidth

你说的曾经没有我的故事 提交于 2020-01-13 14:40:23
问题 I have two UILabel in a custom tableViewCell . One label has width constraints and is set to adjustFontSizeToFitWidth on smaller screens e.g. 5S. How can I get the other UILabel to match the font size of the first label, when it does not have particular width constraints? It seems sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode: was deprecated in iOS7, so what is the Swift solution? This answer When do adjustsFontSizeToFitWidth or boundingRectWithSize change the context