Tag: uitableview

我怎样才能从类别表中重新加载RootViewController中列出的tableView?

我在做一个笑话应用程序。 主页是RootViewController从类别表中列出的类别列表。 数据库在用户执行更改时更新。 问题是当我回到主页时,表格没有刷新。 当我再次运行应用程序时,更改是可见的。 我试过[tableView reloadData]和[self.tableView reloadData]但没有结果。 这里代码: – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { WhySoSeriousAppDelegate *appDelegate = (WhySoSeriousAppDelegate *)[[UIApplication sharedApplication] delegate]; return appDelegate.jokes.count; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = […]

cellForRowAtIndexPath不被调用?

我的cellForRowAtIndexPath不会每次我设置dataSource和delegate给文件的所有者。 我也设置了参考sockets。 我也试试tbl.delegate=self; 和tbl.datasource=self; 但它不起作用。 我能做什么? -(void)load { [name resignFirstResponder]; [salary resignFirstResponder]; name.text=@""; salary.text=@""; [tblViewController.data removeAllObjects]; NSString *insertStatement = [NSString stringWithFormat:@"select * from emp"]; sqlite3_stmt *statement; NSString *path= [self getDBPath]; if (sqlite3_open([path UTF8String], &db) == SQLITE_OK) { if (sqlite3_prepare_v2(db, [insertStatement UTF8String], -1,&statement, NULL) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { NSMutableDictionary *record=[[NSMutableDictionary alloc]init]; NSString […]

无法让UITableViewControllerdynamic填充

我正在关注如何填充表视图的一些基本教程。 我已经成功了一个UITableView和dynamic填充,但以下相同的步骤是不适合我的UITableViewController。 有什么解释为什么我与控制器有困难? 在UITableViewController中没有像UITableView那样多的信息。 有没有一个原因,为什么每个人似乎都倾向于UITableView? 为了logging,这里是我所遵循的教程: http : //www.ioscreator.com/tutorials/tableview-tutorial-in-ios8-with-swift import UIKit class TestTableViewController: UITableViewController, UITableViewDelegate { let tableData = ["One", "Two", "Three"] override func viewDidLoad() { super.viewDidLoad() // Uncomment the following line to preserve selection between presentations // self.clearsSelectionOnViewWillAppear = false // Uncomment the following line to display an Edit button in the navigation bar […]

JSON和iPhone表格视图

我第一次尝试JSONparsing器,我需要一点帮助当我尝试填充表视图它工作正常,但是当我滚动表或select行应用程序崩溃。 我将不胜感激任何帮助。 这里是我有的文件: #import <UIKit/UIKit.h> @class RootViewController; @interface BooksJsonAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UINavigationController *navigationController; NSMutableArray *statuses; NSMutableData *responseData; } @property(nonatomic, retain)NSMutableArray *statuses; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @end 和 #import "BooksJsonAppDelegate.h" #import "RootViewController.h" #import "SBJson.h" @implementation BooksJsonAppDelegate @synthesize window; @synthesize navigationController,statuses; #pragma mark – #pragma […]

快速滚动时,自定义单元格中的多行标签与下一个单元格重叠

我发现类似的问题几乎被问了几十次,但没有一个答案解决了我的问题(或者我太累了,所以我没有正确地回答问题) 我有一个自定义单元格的表格。 细胞看起来像这样 该单元格的typesResultsViewCell,它是从UITableViewCell派生。 单元格中的最后一个标签是多行单元格。 那个有时与下一个单元格的内容重叠。 这是我的cellForRowAtIndexPath函数 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"StandardSearchResultCell"; ResultsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Configure the cell… Data *theData = [Data getInstance]; Company *theCompany = [theData.results objectAtIndex:indexPath.row]; cell.lblTitle.text = theCompany.DisplayName; cell.lblDescription.text = theCompany.Description; cell.lblAddressPt1.text = theCompany.AddressPt1; cell.lblAddressPt2.text = theCompany.AddressPt2; cell.lblPhone.text = theCompany.Phone; cell.lblEmail.text = […]

iOS:重新加载表格视图不工作

我在UITableView中显示Twitter提要。 它正确加载。 我添加了一个Barbutton项目(刷新)来刷新表格。 但是,单击它不会重新加载表。 onClick函数被调用,但其中的代码不被执行。 //"TwitterViewController.h" #import "ViewController.h" @interface TwitterViewController : UITableViewController – (IBAction)refresh:(id)sender; @end 这里是我的“TwitterViewController.m”的一部分 – (void)viewDidLoad { [super viewDidLoad]; [self loadTweets]; } – (void)loadTweets { STTwitterAPI *twitter = [STTwitterAPI twitterAPIAppOnlyWithConsumerKey:@"consumer key" consumerSecret:@"consumer secret"]; [twitter verifyCredentialsWithSuccessBlock:^(NSString *bearerToken) { [twitter getUserTimelineWithScreenName:@"username" successBlock:^(NSArray *statuses) { self.twitterFeed = [NSMutableArray arrayWithArray:statuses]; [self.tableView reloadData]; } errorBlock:^(NSError *error) { NSLog(@"%@", […]

UISearchBar解雇后resize

我有一个tableviewcontroller与一个button,文本框和一个search栏显示控制器在桌面视图的标题视图。 当我点击search栏,然后在取消或背景桌面视图(closures它),search栏将重新resize,以覆盖整个视图(通过button和文本字段)。 在viewDidLoad我有 self.searchBar.translatesAutoresizingMaskIntoConstraints = YES; 有什么想法吗?

在解散视图的同时传递数据

我正在一个应用程序与两个不同的意见,可以模态地呈现一个“设置”viewController与embedded在其中的tableView。 为了将数据从embedded的tableView传递给前两个视图,我将不得不在每个视图转换中使用prepareForSegue(以我的理解)。 但是,当我在“设置”视图中点击“完成”时,我想回到之前的视图。 为了做到这一点,就我所知,人们不得不放弃这个观点。 可否将数据从一个视图传递到另一个视图? 如果没有,这将如何完成? 注意:随时纠正我,我还在开始应用程序开发,我说的一些事情可能是完全错误的。

在我的TableView中实现一个SearchBar,并使用NSFetchedResultsController和适当的谓词来使search工作

我有一个简单的TableViewController,它有一个添加button,转到一个ModalViewController; 用户将文本添加到文本字段中,按下保存并退出,并将条目添加到Core Data中的Entities and Attributes并显示在TableViewController中。 它运作良好。 我首先用另一个button在桌面视图中拉出一个UISearchBar,然后search结果并将其拉回来; 那工作。 然后,我在TableViewController的底部添加了一个新的选项卡,并设法在那里获得search栏和表格。 现在,我想在单表视图顶部的SearchBar,我希望用户能够键入和dynamicsearchTableView。 我的fetchRequest看起来像这样当前为TableView(没有search栏): NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Transaction" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"occasion.dateOfEvent" ascending:NO selector:@selector(localizedCaseInsensitiveCompare:)]; [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]]; [fetchRequest setFetchBatchSize:20]; //NSPredicate *pred = [NSPredicate predicateWithFormat:@"ANY whoBy.name CONTAINS[c] %@", self.searchBar.text]; //[fetchRequest setPredicate:pred]; NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest […]

调整UILabel的大小并不完全正常

我正在调整表格的cell和UILabel 。 标签似乎被resize,但仍然在一行。 如何处理这个? 标签从故事板中设置为: Line Breaks: Word Wrap; Autoshrink: Fixed Font Size; Lines: 0 CGRect textRect = [cell.sampleLabel.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin attributes: @{NSFontAttributeName:cell.sampleLabel.font} context:nil]; NSLog(@"textRect height: %f", textRect.size.height); cell.sampleLabel.frame = textRect; NSLog(@"label height: %f", cell.sampleLabel.frame.size.height); NSLog : 2013-12-20 11:04:41.623 DevCloud[16613:70b] textRect height: 223.091019 2013-12-20 11:04:41.624 DevCloud[16613:70b] label height: 224.000000 2013-12-20 11:04:41.626 DevCloud[16613:70b] textRect height: 223.091019 […]