Tag: tableview

CAGradientLayer在滚动到UITableView顶部之后位置有误。 迅速

我需要在特定的UITableViewCell底部制作一个阴影。 我做了它,但是当我滚动到底部它工作正常,当我滚动到顶部阴影有错误的位置,它出现在UITableViewCell的顶部。 我尝试了几种方法,但它不适合我。 我读了这个问题和这个问题我该如何解决? func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier(cellReuseIdentifier, forIndexPath: indexPath) as! LifelineLeaderboardTableViewCell // Configure the cell… let lifelineRecentModel = users[indexPath.row] cell.clipsToBounds = false if let currentUserID = DBHelper.instance.mainUserId { if lifelineRecentModel.user.id == currentUserID { cell.setupUserNumberLabelTextColor(true) cell.showBlueLineView(true) // cell.showShadow(true) let shadowView = UIView(frame: cell.bounds) let shadowFrame = […]

sorting描述符不正确或一致

我在4个实体之间使用sorting描述符和集合谓词。 实体一:workoutType关系训练1到多个实体二:workoutSet关系天1到多个实体三:workoutDay关系练习1到多个实体四:workoutExercise 倒数也被设置。 我收到的问题是sortDescriptor在幕后正常工作,但是显示的内容不正确。 例如在我的workoutDay实体,我有stringtypes的属性dayName。 储存值:第1天,第2天,第3天。 当在tableview中运行显示值时:第1天,第3天,第2天。 当我点击从上到下的日子: 第1天….下一个视图控制器显示正确的第1天的数据。 第3天….下一个视图控制器显示第2天的数据(不是第3天)。 第2天….下一个视图控制器显示第3天的数据(不是第2天)。 所以sorting描述符正在工作,但显示的内容与正在select的内容不相关。 码: -(void)fetchWorkoutDays { NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"WorkoutDay"]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"workoutSet = %@", self.workoutSet]; [fetchRequest setPredicate:predicate]; NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"dayName" ascending:YES]; [fetchRequest setSortDescriptors:@[sortDescriptor]]; self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil]; //self.fetchedResultsController.delegate = self; NSError *error; if (![self.fetchedResultsController performFetch:&error]) { […]

IPAD与iPhone的TableView行

我已经创build了一个Universal Master Details应用程序。 我用iPad和iPhone的Storyboard。 我实际上是做一个HTTP请求来检索将在主表视图中呈现所需的数据。 我从requestFinished方法重新加载tableview数据。 – (void)requestFinished:(ASIHTTPRequest *)request { NSString *responseString = [request responseString]; ConversationDataController *dataControllerSingleton = [ConversationDataController sharedInstance]; conversationList = [responseString JSONValue]; [dataControllerSingleton setConversationList:conversationList]; [self.tableView reloadData]; } 我将返回的数据存储在具有名为conversationList的NSMutableArray属性的dataControllerSingleton中。 在numberOfRowsInSection中,我打印出基于fetchedResultsController的部分中的对象数。 我也打印出我的NSMutableArray conversationList中的值的数量。 在numberOfSectionsInTableView我打印出的部分数量。 – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section]; NSLog(@"Number OF Objects in section %lu",(unsigned long)[sectionInfo numberOfObjects]); ConversationDataController *dataControllerSingleton […]

为什么我的tableViewController不加载任何数据?

我创build一个应用程序,在ViewController中的不同button加载到tableViewController不同的菜单。 这些button通过为segue做准备而链接,菜单(数组)通过contentMode链接。 1:早餐菜单和2:午餐菜单。 我已经从某人的帮助设置了这一点,但现在表没有加载任何数据…单元格有3个标签显示项目,信息和价格。 当selectcontentMode时,它将更改代码内的值。 有没有人看到我的代码中的问题? 非常感谢! import UIKit class foodMenuController: UIViewController { override func viewDidLoad() { super.viewDidLoad() func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { let foodMenuController = segue.destinationViewController as! foodTableViewController if segue.identifier == "showBreakfast" { foodMenuController.contentMode = 1 } else if segue.identifier == "showLunch" { foodMenuController.contentMode = 2 } } } override func didReceiveMemoryWarning() { […]

想要像Pinterest一样制作详细视图

我一直在整个周末一直在xcode的观点挣扎,但仍然不能如我所愿。 我想做一个Pinterest的detailview(见下面的链接),但无法find如何做到这一点,它是一个tableview自定义单元格,collectionview或其他什么东西..哪种方法是最简单的方法来构build它? 如果有人为我提供了一些好的投入,我会很感激的。 有一个伟大的未来一周! Pinterest的DeatilView 编辑:这是我现在得到的..但感觉应该有一个更简单的方法.. #import "ViewController.h" enum TableSectionSelected { kUIMainContentSection = 0, kUISecondSection, kUIActivateSection }; @interface ViewController () <UITableViewDelegate, UITableViewDataSource> @property (nonatomic, strong) UIImageView *imageView; @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)]; self.imageView.image = [UIImage imageNamed:@"fotolia_54424692.jpg"]; } – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } […]

从CloudKitlogging中selectcreationDate

我试图用标题和副标题来填充单元格。 标题与字段和细节与CreationDate从logging。 我正在尝试以下,但我得到一个没有成员'ObjectForKey' var objects = CKRecord override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let reuseIdentifier = "Cell" var cell:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as UITableViewCell? if (cell != nil) { cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: reuseIdentifier) } let object = objects[indexPath.row] cell!.textLabel!.text = object.objectForKey("Notes") as? String cell!.detailTextLabel?.text = object.creationDate.objectForKey("Notes") as? String return cell! […]

Swift:didSelectItemAtIndexpath函数不工作的JSON

我有三个控制器。 在第一个CategoryCollectionViewController,下一个listTableViewController,最后有DescriptionCollectionViewController。 在控制器中完美地传递了json数据。 但我不知道什么代码我应该写在ListTableViewController的didSelectRowAt_indexPath函数。 第一个CategoryCollectionViewController override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let controller1 = ListTableView() controller1.product_id = arrCategory[indexPath.item].id! navigationController?.pushViewController(controller1, animated: true) } ** CategoryCollectionViewController Json网页文件** 第二个ListTableViewController override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tell me please what code i have to write here for push ViewController } ListTableController和DescriptionCollectionViewController的json网页文件是一样的 只是不同的是product_image值必须在ListTableViewController的单元格中加载,all_images的值必须在DescriptionCollectionViewController的单元格中加载。

基于textView中的内容的iOS大小的表格行

我正在尝试在我的表中调整行的大小到textView的高度,以便用户不必滚动textView,而是滚动表格。 到目前为止我已经实现的东西似乎大部分时间都在工作,尽pipe有时候行高有点太小,迫使用户滚动一下textview,或者行高过多,在文本结束后会产生大量的空白。 我怎样才能正确的框架? 码: – (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Set the textview frame CGRect frame = self.contentTextView.frame; frame.size.height = [self.summary boundingRectWithSize:CGSizeMake(280, 0) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:self.contentTextView.font} context:nil].size.height + 60; self.contentTextView.frame = frame; } – (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { // Return the height for the rows if (indexPath.section == 0) { return 60; } if (indexPath.section […]

设置自定义单元格的标签

我有一个自定义表格单元格,我只是试图设置标签,图像等,但由于某种原因,它不工作。 这是我的自定义单元格的代码 BrowserMenuCell.h #import <UIKit/UIKit.h> @interface BrowseMenuCell : UITableViewCell @property (strong, nonatomic) IBOutlet UIButton *wishListBUtton; @property (strong, nonatomic) IBOutlet UIImageView *itemImage; @property (strong, nonatomic) IBOutlet UILabel *itemLabel; @property (strong, nonatomic) IBOutlet UILabel *itemPrice; @property (strong, nonatomic) IBOutlet UITextField *quantityField; @property (strong, nonatomic) IBOutlet UILabel *totalLabel; – (IBAction)plusButton:(id)sender; – (IBAction)cartButton:(id)sender; – (IBAction)minusButton:(id)sender; @end BrowserMenuCell.m #import "BrowseMenuCell.h" […]

UIView不在两个标题视图中显示

我正在开发一个iPad应用程序。 由于某些原因,我需要在同一个视图控制器中显示two tableviews 。 我在xib创build了一个UIView ,并将一个outlet连接到该view controller 。 我需要在这两个tableviews中将这个视图显示为tableHeaderView 。 当我试图将这个视图分配给both header views ,它只显示在second tableview 。我希望有一个单一的实例,该视图。 所以只有在我最后指定的观点中才显示出来。 我怎么能克服这个? 任何帮助,将不胜感激。 这里是我的代码。 [energyTableView setTableHeaderView:tableHeader]; [maintenanceTableView setTableHeaderView:tableHeader]; @CodeBySteveZ 正如他所说,我创build了一个xib并尝试过。 而我仍然无法得到解决scheme。 我做错了什么?这是我如何尝试。 NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"tableHeaderCell" owner:nil options:nil]; [energyTableView setTableHeaderView:[topLevelObjects objectAtIndex:0]]; [maintenanceTableView setTableHeaderView:[topLevelObjects objectAtIndex:0]]; 我认为这也是我之前做的事情。