Tag: uitableview

Swift在UITableView中添加页脚视图

这实际上是一个tableview和tableview单元格,我想在tableview单元格的末尾添加一个Submitbutton,但是我该怎么做呢? 我试图在故事板上手动添加button,但它不工作,button不显示。 有没有其他办法可以做到这一点? 我想要做下面的截图。

更改单个单元格UITableView的高度

我想要像下面这样的东西: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("NewsCell", forIndexPath: indexPath) as! UITableViewCell if indexPath == 3{ cell.height = "50dp" } return cell } 这是什么select或最简单的方法呢? 编辑 是否可以指定章节号码:ie- if sectionIndex == 5

iOS8 Swift:deleteRowsAtIndexPaths崩溃

我在Swift,iOS 8,Xcode 6 Beta 6中从我的tableView中删除一行时遇到了一些麻烦。每当我尝试删除一行时,我得到一个错误 声明失败 – [UITableView _endCellAnimationsWithContext:],/SourceCache/UIKit_Sim/UIKit-3302.3.1/UITableView.m:1581 2014-08-30 20:31:00.971 Class Directory [13290:3241692] ***终止应用程序,由于未捕获的exception'NSInternalInconsistencyException',原因:'更新无效:第1部分中的行数无效。更新(25)后现有部分中包含的行数必须等于更新前该部分中包含的行数(25),加上或减去从该部分插入或删除的行数(插入0,删除1),加上或减去移入或移出该部分的行数(移入0,移出0)。 我已经阅读了这个常见问题的所有答案,并且觉得我已经达到了所推荐的条件。 该项目似乎从数据模型中删除 – 当我重新加载应用程序,删除的项目从表中消失 – 但似乎有适当的sqlite文件中的遗留物,当然,math不加起来。 吐出indexPath的println显示正确的Section和Row。 我很困惑。 这应该是直截了当,但我失去了一些愚蠢的,我确信,我怀疑在数据模型删除。 在Github上完整的项目。 func numberOfSectionsInTableView(tableView: UITableView!) -> Int { return fetchedResultController.sections.count } func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { return fetchedResultController.sections[section].numberOfObjects } func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { […]

在AFNetworking成功调用后self.tableView reloadData不工作

我有一个运行类似于本教程的AFHTTPSessionManager组件的类http://www.raywenderlich.com/59255/afnetworking-2-0-tutorial 但是,[self.tableView reloadData]不适合我。 我有这样的经理实施: -(void) refresh{ manager = [[AFHTTPSessionManager…] iniwithBaseURL:…]; [manager Get:… parameters:… success:^(NSURLSessionDataTask *task, id responseObject){ //test success values in responseObject if(test){ //Get table data [self.tableView reloadData]; } } …. } 但是,如果我后来运行[self.tableView reloadData]在一个单独的函数,它工作得很好。 为什么会发生这种情况,而不是如何在教程中?

断言失败 – ,/ SourceCache /UIKit_Sim/UIKit-2903.2/UITableView.m:7768

我试图显示与UIToolBar UIPickerView但出现一些错误。 这是我的代码 – CGRect toolbarTargetFrame = CGRectMake(0, self.view.bounds.size.height-216-44, 320, 44); CGRect datePickerTargetFrame = CGRectMake(0, self.view.bounds.size.height-216, 320, 216); UIView *darkView = [[UIView alloc] initWithFrame:self.view.bounds]; darkView.alpha = 0; darkView.backgroundColor = [UIColor blackColor]; darkView.tag = 9; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissDatePicker:)]; [darkView addGestureRecognizer:tapGesture]; [self.view addSubview:darkView]; UIDatePicker *picker = [[UIDatePicker alloc] init]; picker.autoresizingMask = UIViewAutoresizingFlexibleWidth; picker.datePickerMode […]

保留UITableViewCellselect状态

我已经从字面上尝试了所有我能想到的事情。 任何人都可以找出为什么UITableViewCell不select,滚动,然后滚动后不重新加载复选标记? – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { #define CHECK_NULL_STRING(str) ([str isKindOfClass:[NSNull class]] || !str)?@"":str static NSString *CellIdentifier = @"inviteCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark; cell.textLabel.highlightedTextColor = [UIColor colorWithHexString:@"#669900"]; cell.selectionStyle = UITableViewCellSelectionStyleGray; cell.backgroundColor = [UIColor blackColor]; cell.textLabel.textColor = [UIColor whiteColor]; [[UITableViewCell appearance] setTintColor:[UIColor colorWithHexString:@"#669900"]]; if (cell == nil) { cell […]

当我重新使用它时,如何完全清除单元格?

当我调用[table reloaddata]; 单元格会重新绘制新的数据,但是我的UILabel会因为被拖到旧的UILabel上而变得混乱起来,所以一团糟。 static NSString* PlaceholderCellIdentifier = @"PlaceholderCell"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease]; cell.detailTextLabel.textAlignment = UITextAlignmentCenter; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.contentView.backgroundColor = [UIColor clearColor]; } 是我的初始细胞。 我像这样添加一个UILabel UILabel *theDateLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 35,140, 20)]; [theDateLabel setBackgroundColor:[UIColor clearColor]]; [theDateLabel setTextColor:[UIColor lightGrayColor]]; [theDateLabel setText:[dateFormatter stringFromDate:theDate]]; […]

如何添加表格视图节标题与下标?

在我的应用程序中,我有一个表格视图,到目前为止我已经使用storyboard(我已经添加了部分:rows:cells等等,全部通过storyboard),唯一的改变是编程式的添加一个UIButton作为部分标题通过执行: – (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 2) { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 64)]; UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button1 setTitle:@"Hydro Volume" forState:UIControlStateNormal]; button1.frame = CGRectMake(62.5, 5, 205, 44); [view addSubview:button1]; [button1 addTarget: self action: @selector(buttonClicked:) forControlEvents: UIControlEventTouchDown]; return view; } return nil; } 我目前的困境是,我不得不添加一个包含下标的节标题,即:H2O 我无法直接在故事板检查器中添加下标,有人可以告诉我怎么做到这一点? 我回顾了这个问题 ,但它不是我正在寻找的,因为我需要能够将其添加到我的部分标题。

自动select单元格的UITableView

我的UITableView通过PopOverViewController打开,所以如何加载应用程序后自动加载这些单元格之一, MainViewController上的单元格select过程 – (void)setDetailItem:(id)newDetailItem { if (detailItem != newDetailItem) { [detailItem release]; detailItem = [newDetailItem retain]; //—update the view— label.text = [detailItem description]; } } 和TableViewController中的单元格select: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { myAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; appDelegate.viewController.detailItem = [list objectAtIndex:indexPath.row]; } 我在TableViewController中使用此代码,但不起作用! 这意味着按下popOverbutton后,代码将突出显示单元格! [myTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0]; 我用上面的代码在不同的方法,如viewDidAppear , viewWillAppear和didSelectRowAtIndexPath和… 谢谢

如何防止search栏在滚动消失? iOS Swift

我正在创build一个联系应用程序。 我有一个滚动条在我的表视图的顶部。 当我向下滚动search栏消失。 如何防止search栏在滚动消失? 我希望它像第一张照片一样始终保持在页面顶部。 这是我的故事板的图片: 这是我的视图控制器代码,如果解决scheme不在故事板中: class ViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating { //manages search bar var searchController:UISearchController! var contacts = [Contact]() //array to hold contacts that match the search results var filteredContacts = [Contact]() override func viewDidLoad() { super.viewDidLoad() //initialize the defaults manager class NSUserDefaultsManager.initializeDefaults() //search controller searchController = UISearchController(searchResultsController: nil) searchController.searchBar.sizeToFit() tableView.tableHeaderView […]