uitableview

[UILabel numberOfComponentsInPickerView:]: unrecognized selector sent to instance …]

浪子不回头ぞ 提交于 2020-01-16 05:18:06
问题 In my iOS app I have created a table view controller with custom cells where one of them contains a PickerView. Here's the class for that custom cell: import Foundation import UIKit class PickerCell: UITableViewCell { @IBOutlet weak var label : UILabel! @IBOutlet weak var pickerView : UIPickerView! func configurePickerCell(labelText:String, pickerDelegate:MyPickerViewController, enabled:Bool, defaultValueIndex:Int) { self.label.text = labelText var labelFrame:CGRect = self.label.frame

How do I get the default cell separator color? Also, how do I set separator color per cell?

送分小仙女□ 提交于 2020-01-16 04:45:07
问题 I want to add a cell in the bottom that shows only if the app is loading more results when the user scrolls to the bottom of a tableview. I already did that. The problem is that it's a cell. So when I scroll down even further, the separator shows that it's just another cell in the table. I want to hide that. I have to change that cell's separator color, how do I do that to a particular cell? Also, Where/when do i do that? I realize that if I change that cell's color (let's say it's #5), when

iOS开发 给TableView增加SearchBar

无人久伴 提交于 2020-01-16 04:33:36
效果如图: 可以根据输入的关键字,在TableView中显示符合的数据。 图中分组显示和索引效果,前面的博文已经记录,不再赘述。下面的例子是基于前文的基础上修改的,所以文件名啥的,请参考前文。 第一步是在TableView上方添加一个Search Bar,这里有一点需要注意,必须先把TableView拖下来,留下空间放Search Bar,不要在Table View占满屏幕的情况下把Search Bar拖到Table View顶部。区别在于,使用后面的方法,Search Bar是作为Table View的Header部分添加的,而前面的方法,Search Bar是独立的。在添加索引功能时,如果作为Table View的Header添加,右侧的索引会遮住Search Bar的右边部分。Search Bar几个常用属性: Placeholder是提示,就是hint属性,Corretion是自动修正,一般设为NO,即不修正,Show Cancel Button是显示取消按钮,我这里勾选。选中Search Bar的情况下切换到Connections Inspector面板,delegate与File’s Owner建立连接(我们会在ViewController中支持UISearchBarDelegate协议)。与前面几篇文章的例子相 同

Empty UITableView not bouncing when loaded from a nib

一个人想着一个人 提交于 2020-01-16 03:30:33
问题 A UITableView should bounce (even when empty) when user scrolls as long as the bounces and alwaysBounceVertical properties are set to YES. When I initialize a UITableViewController, everything works as expected. When I initialized a UIViewController loaded from a nib with a simple view hierarchy: a top level UIView with a single UITableView child, then the table view doesn't bounce anymore. Here is the code I used: #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder

How to support auto resizing UITableViewCell with a UILabel in it

…衆ロ難τιáo~ 提交于 2020-01-16 03:08:05
问题 I am trying to figure out how get the correct height for my tableview cell that contains a uitextview so that all the content in the uitextview will be display. The textview is not editable and not scrollable, which means that the string for the uitextview is known. I tried simply returning the height of the tableview cell that is in the storyboard in heightForRowAtIndexPath but that cuts off the content if it is too large. I also tried calculating the height for the textView in

Tableview如何实现流畅的展开折叠?

蓝咒 提交于 2020-01-16 02:27:15
上周做了一个tableview的展开折叠,好久不用,生疏好多,结果各种纠结蛋疼,效果各种不好,索性不弄了,浪了两天之后,周一来了灵感突发,一气呵成,效果感觉还不错,废话不多说,说下具体流程   1.tableview的style:UITableViewStylePlain(很重要,直接影响动画视觉效果)   2.通过scrollview的代理控制禁止header悬停,这里就很蛋疼了(万恶的Oc),设置成让他悬停再禁止掉就是为了动画的视觉效果醉了醉了下面是代码 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView == self.tableView) { CGFloat sectionHeaderHeight = 100 * KY_Proportion; //sectionHeaderHeight if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) { scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0); } else if (scrollView

ios中tableview侧栏的折叠

喜欢而已 提交于 2020-01-16 02:25:09
#import "ViewController.h" #define Ksmall 40.0f #define Klarge 80.0f #define KNoOpen @"NoOpen" @interface ViewController (){ int flag; } @property(nonatomic,retain)NSMutableDictionary *mydata; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.mydata=[NSMutableDictionary dictionary]; UITableView *tableview=[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; tableview.delegate=self; tableview.dataSource=self; [self.view addSubview:tableview]; [tableview release]; // Do any additional setup after loading the view, typically from a

tableView折叠

99封情书 提交于 2020-01-16 02:21:42
#import <UIKit/UIKit.h> @class CZFriendGroup; @class CZHeaderView; @protocol CZHeaderViewDelegate <NSObject> @optional - (void)headerViewDidClickedNameView:(CZHeaderView *)headerView; @end @interface CZHeaderView : UITableViewHeaderFooterView @property (nonatomic, strong) CZFriendGroup *friendGroup; @property (nonatomic, weak) id<CZHeaderViewDelegate> delegate; + (instancetype)headerViewWithTableView:(UITableView *)tableView; @end #import "CZHeaderView.h" #import "CZFriendGroup.h" @interface CZHeaderView () @property (nonatomic, weak) UIButton *nameView; @property (nonatomic, weak) UILabel

如何在UINavigationBar上添加UISearchBar以及UISearchDisplayController的使用 --OC --iOS

▼魔方 西西 提交于 2020-01-16 02:20:51
那我们开始吧,下面是Sely写的一个Demo,分享给大家。 新建一个项目, UISearchDisplayController 的 displaysSearchBarInNavigationBar太死板了,达不到想要的效果。 这里进行重新定制, 四个协议, 三个成员变量,第一步OK。 @interface ViewController ()<UISearchBarDelegate,UISearchDisplayDelegate, UITableViewDataSource, UITableViewDelegate> { UISearchBar *mySearchBar; UISearchDisplayController *mySearchDisplayController; NSMutableArray *suggestResults; } @end //下面我们来初始化我们的三个成员 -(void)initMysearchBarAndMysearchDisPlay { mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, [UIApplicationsharedApplication].statusBarFrame.size.height, [UIScreen mainScreen].bounds.size

UITableView redraw issue on scrolling

本秂侑毒 提交于 2020-01-16 01:55:12
问题 I have a grouped UITableView that I populate from a list. On some rows I don't want to have disclosure and on some I need to add label. But is somehow mix something and add labels on wrong rows and display disclosures at each row. What am I doing wrong here? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if