uitableview

IOS开发实训第八周周报

依然范特西╮ 提交于 2020-01-30 05:10:40
IOS开发实训第八周周报 总结: 根据小组分工,本周我学习的知识点有:对于个人页面的用户收藏列表和浏览列表,进行优化,包括: (1)如何进行UITableViewCell的格式自定义 (2)UITableViewCell自适应地高度 (3)学习UITableViewCell的缓存机制 学习知识点归纳 1. 自定义UITableViewCell 自定义UITableViewCell有两种形式:纯代码定义与xib格式定义 (1)纯代码定义 创建UITableViewCell的子类,作为自定义Cell,并重写初始化函数:initWithStyle:withReuseableCellIdentifier,完成Cell内部子控件的声明与加载; - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if(self) { [self setMyView]; } return self; } 在使用之前,需要为这个Cell注册一个CellIdentifier,以便于系统缓存重用的cell: [ tableView

UILabels in custom UITableViewCell never gets initialized

吃可爱长大的小学妹 提交于 2020-01-30 05:01:34
问题 I'm having trouble creating custom table view cells in swift with Xcode6 (beta 4). More precisely I'm unable to access (unwrap) my custom UILabels inside the cell, since they never gets initialized. Here's how I've got it all setup: I've made a view in storyboard, which contains a table view with a prototype cell: The view is hooked up to a class MyCoursesTableViewController, and the cell (with identifier courseCell) to CourseTableViewCell. I've pasted both classes below (with just the

UITableView changing things of some cells in Swift

自作多情 提交于 2020-01-30 03:30:19
问题 I have a UITableView with a custom UITalbeCellView . Every cell has a title a body and a date. When I fetch the data some of the titles must be red so there is a Bool that is set to true for those cells which title has to be red. The first time the data is fetched it looks fine, but as you scroll up and down a few times all of the titles end up being red . Im using an array of structures to store the data and on the cellForRowAtIndexPath there is an if and if the boolean in that position of

ios中自定义checkbox

五迷三道 提交于 2020-01-29 14:28:46
//自定义button#import <UIKit/UIKit.h> @interface CKButton : UIButton @end #import "CKButton.h" #define KTitleWidth 0.6 #define KPadding 0.1 #define KImageWidth (1-KTitleWidth -2*KPadding) @implementation CKButton - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code //设置image self.adjustsImageWhenDisabled=NO; self.adjustsImageWhenHighlighted=NO; self.imageView.contentMode=UIViewContentModeScaleAspectFit; //设置title [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } return self; } -(CGRect)imageRectForContentRect:(CGRect

Adding drop shadow to UITableView

不羁的心 提交于 2020-01-29 02:52:08
问题 I've a plain UITableView (not grouped) that I want to add a dropshadow to left and to the right. How can I achieve this? I've tried: [self.tableView.layer setShadowColor:[[UIColor whiteColor] CGColor]]; [self.tableView.layer setShadowOffset:CGSizeMake(0, 0)]; [self.tableView.layer setShadowRadius:5.0]; [self.tableView.layer setShadowOpacity:1]; but it doesn't work. 回答1: You need to make sure clipsToBounds and masksToBounds are set to NO on the view and layer respectively. self.tableView

What would be a good data structure for UITableView in grouped mode

余生颓废 提交于 2020-01-28 09:40:23
问题 Usually I store data in an array. Then, when cellForRowAtIndexPath is called I just look at row and select an item on the array based on row and process. But UITableView as we know can do group view. So what should I do? Should I have an array of array? An NSDictionary of array? What would be the most elegant way to store data in UITableView structure? 回答1: For example an array of dictionaries, where each dictionary holds the title and all items of one section: NSArray *dataSource = @[ @{@

What would be a good data structure for UITableView in grouped mode

十年热恋 提交于 2020-01-28 09:39:26
问题 Usually I store data in an array. Then, when cellForRowAtIndexPath is called I just look at row and select an item on the array based on row and process. But UITableView as we know can do group view. So what should I do? Should I have an array of array? An NSDictionary of array? What would be the most elegant way to store data in UITableView structure? 回答1: For example an array of dictionaries, where each dictionary holds the title and all items of one section: NSArray *dataSource = @[ @{@

How do you make a UITextView detect link part in the text and still have userInteractionDisabled?

送分小仙女□ 提交于 2020-01-28 09:19:12
问题 I have a textView that is layered on a tableView cell. I need the user to click on the tableView row to open a viewController but if the textView has a link it must be clickable and that's it, no copy, select etc. If I allow user interaction like this: textView.userInteractionEnabled=NO; textView.dataDetectorTypes =UIDataDetectorTypeLink; the didSelectRowAtIndexPath is not called and I understand why but how to achieve this? EDIT: What I'm looking for is the ability to specifically identify

UITextViews in a UITableView link detection bug in iOS 7

一笑奈何 提交于 2020-01-26 23:57:48
问题 I have custom UITableViewCells that contain a UITextView. I have link detection in the UITextView turned on in Interface Builder. When I first load the table view, everything seems to be working, but as I scroll up and down the table view, the link detection gets messed up. Specifically, cells that just have regular text (which are presented normally initially) are being shown as links (all the text in the text view is coloured blue and is an active link), and the links point to objects that

Stange animation when deleting UITableViewCell

帅比萌擦擦* 提交于 2020-01-26 04:28:04
问题 I'm using this code to delete a UITableViewCell, but when I swipe to delete, it is showing the minus sign on the right first, then deleting. I took a video to help illustrate my point: Video on YouTube - (void)setEditing:(BOOL)editing animated:(BOOL)animate { [self.tableView setEditing: !self.tableView.editing animated:YES]; if (self.tableView.editing) [self.navigationItem.leftBarButtonItem setTitle:@"Done"]; else [self.navigationItem.leftBarButtonItem setTitle:@"Edit"]; } -(void)tableView: