Tag: uitableview

UITableView不重载数据或调用cellForRowAtIndexPath

我有一个严重的问题与UITableView的reloadData方法。 我有一个UIViewController类,它有一个UITableView和NSMuttableArray 。 我目前正在AppDelegate发布networking调用,并在数据下载WiGiMainViewController后向WiGiMainViewController发布通知。 在我的通知reloadWigiList的select器方法中,我传递了一个包含最近下载的项目的NSArray 。 然后用传入的数组初始化WiGiMainViewController的NSMuttableArray ,并继续在我的UITableView对象上调用reloadData() 。 我可以从NSLog语句中看到numberOfRowsInSection在刷新时触发,但不是cellForRowAtIndexPath ,因此导致UI不重新加载UITableView与新下载的项目。 我已经validation了在主线程上调用了reloadData方法,并且在IB中设置了数据源委托,并在WiGiMainViewController的viewDidLoad方法中以编程方式进行了设置。 任何想法为什么我的UITableView ,wigiLists不重新加载数据,特别是不调用cellForRowAtIndexPath方法? @interface WiGiMainViewController : UIViewController<FBRequestDelegate,UITableViewDelegate, UITableViewDataSource> { //setup UI UITableView *wigiLists; WiGiAppDelegate *myAppDelegate; NSMutableArray *itemsList; } @property (nonatomic, retain) WiGiAppDelegate *myAppDelegate; @property (nonatomic, retain) IBOutlet UITableView *wigiLists; @property (nonatomic, retain) NSMutableArray *itemsList; -(void) reloadWigiList: (NSNotification*) notification; -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView; -(NSInteger) tableView: (UITableView*) […]

如何通过点击一个UITableViewCell加载UIDatePicker

我有一个正常的UITableView与它的一些常规的UITableViewCell 。 而且我知道如何将UIDatePicker连接到UITextField 。 但现在我想知道是否可以通过点击整个单元来呈现拾取器,即使没有文本字段。 我所尝试的是,我添加了一个UIToolBar作为子视图在select器上,并把代码[self showPicker]在UITableViewDelegate方法之一: didSelectRowAtIndexPath ,然后当我点击单元格的select器显示,如我所愿。 但问题是,当我点击我放在前面的工具栏的UIBarButtonItembutton,它没有触发它的行动,即使我添加目标和行动像一个普通的button应该有。 如果你想看到一些代码,这里是自定义方法showPicker和常规的东西: -(void)loadBirthdayPicker { CGFloat pickerWidth = kScreenWidth; CGFloat pickerHeight = kScreenHeight/3; CGFloat toolHeight = 40; CGFloat toolWidth = kScreenWidth; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonPressed:)]; UIBarButtonItem *flexibleSpaceMiddle = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(doneButtonPressed:)]; […]

iOS滚动UITableView时展开/select的自定义UITableViewCells状态更改

我有我的tableview中的自定义单元格的列表,当我滚动一切似乎罚款和单元格似乎是在相同的顺序。 我有我的单元格的一些function – 当我select一个单元格(并dynamic扩展)背景颜色的变化和一些其他自定义单元格属性。 一旦我这样做,然后我开始滚动,不同的单元格,我甚至没有触及之前显示,select(扩大),单元格只有当我手动select到正确的数据更新。 我似乎看到重复和各种疯狂。 我知道这里有很多关于这个的post,但是对于我来说,到目前为止还没有任何工作。 想就我能做些什么来阻止这种荒谬的行为的一些投入。 我已经发布了一些代码,让你更好地了解我在做什么。 我知道'dequeueReusableCellWithIdentifier'是罪魁祸首,但不知道替代。 作为旁注,这是一个tableview(它自己的xib),它是一个大视图的子视图(也是一个xib)。 我也已经注册了桌面视图的笔尖。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:myIndentifier forIndexPath:indexPath]; if(self.currentSelectedIndex){ if(self.previousSelectedIndex){ //collapse cell //configure cell in method(change background color etc) } else{ //expand cell //configure cell in method(change background color etc) } } } – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath […]

UISearchBar与NavigationBar上隐藏的TableView

我试图用NavigationBar上的searchBar创build一个视图,我希望这个searchBar在打字开始的时候用search结果打开一个tableView,并且一旦一个物品被触摸就隐藏它。 我是这个平台的新手,所以我只需要一条path,我不知道从哪里开始。

如何通过键和值获得对象

我有一个名为masterMessages的对象,里面充满了称为消息的对象。 每个消息对象有五个键: OBJECTID 发件人ID 发件人名称 邮件正文 时间戳 基本上我现在正在做的是查询所有的消息发送到我的用户在这个对象称为masterMessages。 然后我使用: self.senderIds = [masterMessages valueForKeyPath:@"@distinctUnionOfObjects.senderId"]; 在名为senderIds的数组中获取所有不同的发件人ID(senderId)。 有了这个,我将填充我的对话表。 但我想填充发件人名称(senderName)而不是senderIds。 我只是这样做,以防两名用户有相同的名字。 我试图find: 我怎么说“get valueForKey:@”senderName“这个senderId 和 有没有更好的方式来填充我的对话表? 这是我的代码: 注意:即时通讯使用parse.com -(void)viewWillAppear:(BOOL)animated{ NSString *userId = [[PFUser currentUser] objectId]; PFQuery *query = [PFQuery queryWithClassName:@"lean"]; [query whereKey:@"recipientId" equalTo:userId]; [query orderByDescending:@"createdAt"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (error) { NSLog(@"Error: %@ %@", error, [error […]

Swift将PFQuery转换为TableView的string数组

我试图查询我的数据库中的所有parsing用户,然后在tableview中显示每个单独的用户在他们自己的单元格。 我已经build立了我的tableview,但我坚持把用户查询保存到可以在tableview中使用的string数组。 我创build了一个loadParseData函数,在后台查找对象,然后将查询的对象追加到string数组中。 不幸的是,我在附加数据的行上给出了一条错误消息。 Implicit user of 'self' in closure; use 'self.' to make capture semantics explicit' Implicit user of 'self' in closure; use 'self.' to make capture semantics explicit'在我看来,这是我build议使用self. 而不是usersArray. 因为这是在一个闭包,但我给了另一个错误,如果我这样运行, *classname* does not have a member named 'append' 这是我的代码: import UIKit class SearchUsersRegistrationViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var userArray = [String]() @IBOutlet var […]

导航控制器标题不显示

所以,在这里我基本上有这个布局 但是当我成功构build时,我无法看到导航控制器的标题。 我能做什么?

UITableViewCellbutton标签在UISearchController中返回所需的IndexPath,而不是FetchedResultsController

我在Swift 2.0的Core Data项目的UITableView上实现了NSFetchedResultsController 。 另外,我有一个UISearchController实现。 除了我在自定义的UITableViewCellbutton上遇到的行为之外,一切都可以正常工作。 当UISearchController处于活动状态时, customTableViewCell的button按照它们应该的方式工作。 如果在fetchedResultsController显示其结果时单击相同的button,则方法认为索引0是发件人,无论我单击哪个button。 func playMP3File(sender: AnyObject) { if resultsSearchController.active { // ** THIS WORKS ** // get a hold of my song // (self.filteredSounds is an Array) let soundToPlay = self.filteredSounds[sender.tag] // grab an attribute let soundFilename = soundToPlay.soundFilename as String // feed the attribute to an initializer of […]

Swift:tableView

我有以下tableView定义: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("ProductCell", forIndexPath:indexPath) print("Pass it to tableview \(courseName2) ") print("Pass it to tableview \(codeName2) ") var count = 0 getTime( (self.courseName2!), courseCode: (self.codeName2!), completion:{(success:[ClassSchedule]) -> Void in count = classes[0].total! print("TOTAL CKASSESSSs \(count) ") dispatch_async(dispatch_get_main_queue(),{ self.tableView.reloadData() for var i = 0; i […]

iOS使用Plist中的数据填充UITableView

我想用我的Data.plist文件的内容填充一个UTTableView 。 我需要加载到一个NSMutableArray 。 这是我来了多远: (查看加载): NSString *PlistPath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; Array = [[NSMutableArray alloc] initWithContentsOfFile:PlistPath]; [Array addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Testing 1", @"name", nil]]; 当然,在CellForRowAtIndexPath : cell.textLabel.text = [Array objectAtIndex:indexPath.row]; 我写在我的Data.plist文件(图片): 现在,当我运行该应用程序。 我的TableView保持空白。 感谢您的时间和帮助!