Tag: 可用

重构iOS7和iOS8的UITableView委托

作为这个问题的后续行动: 在iOS中跳过/忽略方法 ,我试图在iOS7和iOS8中为我的UITableView实现单独的委托。 所以,作为第一步,在MyTableViewController viewDidLoad中,我添加了下面的代码: if ([[[UIDevice currentDevice] systemVersion] compare: @"8.0" options: NSNumericSearch] != NSOrderedAscending) { [self.tableView setDelegate: [[MyTVDelegate alloc] initWithIdentifier: myTVCellIdentifier]]; } else { [self.tableView setDelegate: [[MyTVDelegate7 alloc] initWithIdentifier: myTVCellIdentifier]]; } 我添加一个标识符,因为我将不得不将这个应用到多个视图控制器(或者我可能只是为每个电视创build一个委托类,我还没有想出来)。 我正在使用CoreData ,所以我的dataSource是一个NSFetchedResultsController 。 然后,我有以下MyTVDelegate/myTVDelegate7 : #import "MyTVDelegate.h" @implementation MyTVDelegate – (instancetype)initWithIdentifier: (NSString *) identifier { if ([super init]) { self.identifier = identifier; […]

iOS UITableView numberOfRowsInSection在tableView中的heightForRowAtIndexPath给予BAD ACCESS

当我input下面的if语句[tableView numberOfRowsInSection:0]时,我收到一个EXC Bad Access错误。我正在计算tableView numberOfRowsInSection中的UITableView的tableView numberOfRowsInSection 。 我有以下代码来设置第一节的最后一行的高度 -(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.section==0) { NSInteger lastRowIndex = [tableView numberOfRowsInSection:0] – 1; if (indexPath.row==lastRowIndex) { return 44.0f; }else{ return 100; } }else{ return 100; } } 我得到如下图像的错误 我没有发现这种方法适当 iOS UITableView numberOfRowsInSection不良访问 – (int) myNumberOfRowsMethod{ // Here you would usually have some underlying model return […]

请求成员tableView不是结构或联合

请帮助解决这个问题,我试图用coreData db填充我的表格单元格; 我正在移植一个从iPhone到iPad的例子,问题在于我的表格视图中的iPad。 我在用着: @interface FailedBanksViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate> 不是 @interface FailedBanksListViewController : UITableViewController <NSFetchedResultsControllerDelegate> 对于整个表格视图而言, 所以我得到的错误: “请求成员'tableView'的东西不是一个结构或联盟” 对于我的代码, 看下面的代码,我希望是唯一的问题: #import "FailedBanksViewController.h" #import "FailedBankInfo.h" @implementation FailedBanksViewController @synthesize context = _context; @synthesize fetchedResultsController = _fetchedResultsController; – (NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; } NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription […]

2 UITableView在UIViewController互相影响

我已经在这里约3个小时了,我终于把毛巾扔给你们了。 我有2 UITableView在我看来,其中之一是一个论坛董事会留下意见,什么不是,第二个UITableView是用来提人。 我遇到的问题是,即使我只想更新tableview counts中的一个,两个tableview counts受到影响。 我在viewdidload设置委托/数据源 self.mentionTableView.delegate = self; self.mentionTableView.dataSource = self; self.mentionTableView.tag = 1; self.forumTable.delegate = self; self.forumTable.dataSource = self; self.forumTable.tag = 2; 如果我真的不加载feedArray这是哪里forumTable获取其数据,提及部分完美的作品。 我想通了,如果matchedNames.count < feedArray.count一切工作正常,但如果matchedNames.count > feedArray.count它崩溃,这是我得到的错误 -[__NSCFArray objectAtIndex:]: index (1) beyond bounds (1) 这意味着我只有1个项目feedArray和matchedNames有不止一个。 代替 – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 我已经使用这些代码来试图使它工作,甚至没有任何事情,甚至做了他们的组合。 1) if ([tableView isEqual: mentionTableView]){ NSLog(@"%@",matchedNames); NSLog(@"%i",matchedNames.count); return [matchedNames […]

iOS:Tableview开始更新从不播放animation

我写了一些代码,当用户长按一个单元格并确认更改时,从后端和本地数据存储中删除一个post。 但是,tableview不会更新。 我已经突破了我的代码和tableView操作代码被执行,为什么我的行不被从视图中删除? let alertView = UIAlertController(title: "Really?", message: "Are you sure you want to delete this post? Once you do it will be gone forever.", preferredStyle: .Alert) alertView.addAction(UIAlertAction(title: "Delete Post", style: UIAlertActionStyle.Default, handler: { (alertView:UIAlertAction!) -> Void in let p = post.getRawPost() p.deleteInBackgroundWithBlock({ (deleted:Bool, error:NSError?) -> Void in // Remove from the local datastore […]

“尝试将第0行插入到第0部分,但更新后第0部分中只有0行”错误

我有一个应用程序,从他们的联系人列表中select一个人,并采取他们的名字,姓氏和电子邮件。 然后把名字保存到一个nsmutablearray中,并把它放到一个可用的视图单元格中。 一旦在模拟器中select了联系人,就会发生我的问题。 码: 。H: #import <UIKit/UIKit.h> #import <AddressBookUI/AddressBookUI.h> @interface FirstViewController : UIViewController < ABPeoplePickerNavigationControllerDelegate, UITableViewDelegate, UITableViewDataSource> – (IBAction)showPicker:(id)sender; @property (weak, nonatomic) IBOutlet NSString *firstName; @property (weak, nonatomic) IBOutlet NSString *email; @property (weak, nonatomic) IBOutlet NSString *lastName; @property (weak, nonatomic) IBOutlet UITableView *myTableView; @property (strong, nonatomic) NSMutableArray *contacts; @end .M: #import "FirstViewController.h" @interface FirstViewController () […]

无法在UITableViewCell的drawRect中绘制

我在绘制自定义UITableViewCell的drawRect方法时遇到了麻烦。 这是我正在使用的代码 – (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGPoint origin = _faceView.frame.origin; CGFloat width = _faceView.frame.size.width; CGFloat height = _faceView.frame.size.height; CGFloat border = 2.0f; CGPoint startPt = CGPointMake(origin.x + width/2, self.frame.size.height); CGContextBeginPath(ctx); CGContextMoveToPoint(ctx, startPt.x, startPt.y); CGPoint basePt = CGPointMake(startPt.x, origin.y – height – border); CGContextAddLineToPoint(ctx, basePt.x, basePt.y); CGRect circleRect = CGRectMake(origin.x – border, origin.y […]

重复使用同一个故事板中的另一个表VC中的单元格

让我们在故事板中说我有两个表视图控制器(A和B)。 在A控制器中,我创build了具有标识符的单元格原型:VIENS和DU。 在B控制器中,我需要使用标识符为DU的单元。 我不想在B控制器中再次创build相同的外观和感觉单元原型。 这里有一种方法来重新使用B控制器中A控制器的单元DU? 如果是的话那该怎么办呢?

UITableView与UILabel SizeToFit滚动时弄乱

大家好,我有我的问题与我的tableview ,我使用uilabel与SizeToFit单元格,然后计算UILabel高度设置单元格高度一切工作,除非当我滚动我的表tableView文本得到奇怪像每行一个字符: 我的TableViewVell方法是: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } UILabel *label = (UILabel *)[cell viewWithTag:1]; label.text = [someArray objectAtIndex:indexPath.row]; // Set the UILabel to fit my text; messageLabel.lineBreakMode = […]

当tableView滚动时,tableViewCells中的运行计时器被覆盖

我已经试过多次询问这个问题,但是我一直没能解释发生了什么事情。 也许一些屏幕截图可能有帮助。 我只能发布一个,因为我没有足够的声望点。 在tableview滚动后截图 您可以看到其中一个定时器(2)已被重置。 我试图解决这个多种方式没有成功。 下面是将定时器放入tableview单元的代码: -(void) calculateTimer:(NSTimer *)theTimer { self.timerItem = [theTimer userInfo]; // for date only cell if(self.timerItem.timerType == 0){ [theTimer invalidate]; } for (NRCItemCell *cell in [self.tableView visibleCells]) { NSIndexPath *ip = [self.tableView indexPathForCell:cell]; NSUInteger row = [[[NRCItemStore sharedStore]allItems] indexOfObjectIdenticalTo:self.timerItem]; if (row == ip.row){ [self configureTimers:cell forRowAtIndexPath:ip]; cell.timer.text = self.timerItem.timerOutput; cell.timerName.text […]