相关疑难解决方法(0)

何时使用dequeueReusableCellWithIdentifier vs dequeueReusableCellWithIdentifier:forIndexPath

dequeueReusableCellWithIdentifier有两个重载,我试图确定何时使用一个与另一个相比?

关于forIndexPath函数的apple文档声明:"此方法使用索引路径根据表格视图中单元格的位置执行其他配置."

我不知道怎么解释这个?

objective-c ios swift

158
推荐指数
3
解决办法
6万
查看次数

UITableViewController中的断言失败

我正在参加iTunes U Stanford iOS Class,正在开展其中一项任务,以构建一个小小的Flickr应用程序.我收到一个错误,我似乎无法调试出现的错误

*断言失败 - [UITableView _configureCellForDisplay:forIndexPath:],/ SourceCache/UIKit_Sim/UIKit-2280.1/UITableView.m:5336 2012-08-03 10:59:24.596 Assignment 4 [4611:c07](null)libc ++ abi.dylib:终止调用抛出异常

我的tableviewcontroller的代码:

#import "PlacesPhotosTableViewController.h"

@interface PlacesPhotosTableViewController ()
@property (nonatomic) NSDictionary *placeToDisplay;
@property (nonatomic) NSArray *photosInPlace;
@end

@implementation PlacesPhotosTableViewController
@synthesize placeToDisplay = _placeToDisplay;
@synthesize photosInPlace = _photosInPlace;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (id)init
{
    self = [super init];

    return self;
}

- (id)initWithPlace:(NSDictionary *)place
{
    self = [self init];
    if (self) …
Run Code Online (Sandbox Code Playgroud)

flickr uitableview ios

27
推荐指数
1
解决办法
3万
查看次数

无法使用标识符Cell对单元格进行出列 - 必须为标识符注册nib或类,或者在故事板中连接原型单元格?

我正在尝试在用户的库中显示歌曲列表的TableView.我使用了这个tutoria l 的代码(它使用了故事板,但我想以不同的方式尝试它,只使用UITableView的子类).

我收到错误:

*** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-2903.23/UITableView.m:5261
2014-05-07 20:28:55.722 Music App[9629:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
Run Code Online (Sandbox Code Playgroud)

并且Thread 1: SIGABRT该行有错误:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView …
Run Code Online (Sandbox Code Playgroud)

xcode storyboard tableview ios

18
推荐指数
3
解决办法
6万
查看次数

为什么我的UITableView尝试加载时出现无法出队的错误?

我收到以下错误:

*由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无法使用标识符FontCell对单元格进行出列 - 必须为标识符注册一个nib或类或在故事板中连接原型单元格'

我不确定我到底做错了什么.我设置了单元格标识符(以编程方式,因为它不是通过Interface Builder创建的)并且执行我认为我应该在委托方法中执行的所有操作,但是当我尝试加载UITableView时,我仍然会收到该错误.

这是相关的代码(值得注意的是我已经将UITableViewCell子类化为自定义选项):

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.fonts.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"FontCell";

    FontCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

    if (!cell) {
        cell = [[FontCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FontCell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    int row = indexPath.row;

    cell.fontFamilyLabel.text = self.fonts[row];

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

这是我在子类UITableViewCell(FontCell)中更改的唯一方法:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.fontFamilyLabel = …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

15
推荐指数
1
解决办法
3万
查看次数

断言失败 - [UITableView _configureCellForDisplay:forIndexPath:]

谁能告诉我为什么会收到这个错误?

这是我的.m文件:

#import "ListaParticipantesViewController.h"
#import "Participantes.h"
#import "ModParticipantesViewController.h"

@implementation ListaParticipantesViewController

@synthesize dao;
@synthesize participantes;

- (void)viewDidLoad
{
    dao = [[ParticipantesDAO alloc] init];
    participantes = [[NSMutableArray alloc] init];
    participantes = [dao getDatos];
    [super viewDidLoad];

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [participantes count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"celda";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.textLabel.text = [[participantes objectAtIndex:[indexPath row]] valueForKey:@"nombre"];

    return cell;
}

#pragma mark - Table …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios

10
推荐指数
2
解决办法
2万
查看次数

UITableView内容"静态单元格"在iOS7中不起作用

我的故事板有问题.它工作正常但是当我尝试更改UITableView的内容属性时导致以下错误

断言失败 - [UITableView dequeueReusableCellWithIdentifier:forIndexPath:],/ SourceCache/UIKit/UIKit-2903.23/UITableView.m由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无法使用标识符Cell将单元格出列 - 必须注册一个笔尖或标识符的类或连接故事板中的原型单元格'

我想用静态单元格设计一个分组的tableview.Thanks提前

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
// Return the number of sections. 
return 2; 
} 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
return 3; 
} 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
return cell; 
} 
Run Code Online (Sandbox Code Playgroud)

iphone ios7 xcode5

6
推荐指数
3
解决办法
1万
查看次数

断言失败 - [UITableView dequeueRequeableCellWithIdentifier:forIndexPath:]

出于某种原因,我的应用程序在尝试将单元格加载到tableview时失败.我在整个应用程序中的所有表格视图完全相同,我对它们没有任何问题.是否可能与从另一个viewController初始化Controller有关?我不这么认为.故事板中的我的单元格已被赋予标识符.这是一个屏幕截图的链接.

在此输入图像描述

所以我在这里尝试了一切,没有任何效果.

这是使用[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]方法的输出:

2013-11-14 15:36:33.419 ComplyOS[43683:70b] *** Assertion failure in -[UITableView            dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:5261
2013-11-14 15:36:33.424 ComplyOS[43683:70b] *** Terminating app due to uncaught exception    'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier ProcedureCell - must register a    nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0   CoreFoundation                      0x0000000101fa9795 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000101d0c991 objc_exception_throw + 43
2   CoreFoundation                      0x0000000101fa961a +[NSException raise:format:arguments:] + …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview ios

6
推荐指数
1
解决办法
2万
查看次数

为什么在Interface Builder中向UITableViewCell子类添加手势识别器会使应用程序崩溃?

我有一个自定义UITableViewCell子类,我正在尝试使用Interface Builder将一个捏手势识别器添加到其中一个视图中.我的应用崩溃了:

2016-09-11 17:37:22.425 MYAPPNAME[4619:1284144] *** Assertion failure in -[ULFeedView _dequeueReusableViewOfType:withIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.12/UITableView.m:6539

我尝试了不同的手势识别器(例如点击识别器)和不同的子视图,但它们崩溃了我的应用程序.

一个有趣的观察:如果我以编程方式将识别器添加到视图中,它不会崩溃awakeFromNib.

以下是一些可能相关的方法:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if(indexPath.section != SECTION_CONTENT){
        return; //index path section is NOT equal to SECTION CONTENT for the cell in question, so it will always return.
    }
    ...
 }

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.section) {
        case SECTION_MAP:
        {
            ULMapCell *cell = [tableView dequeueReusableCellWithIdentifier:@"map" forIndexPath:indexPath];
            return cell; //the cell in question is this one, …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview uigesturerecognizer ios

5
推荐指数
2
解决办法
1685
查看次数

无法使用标识符将单元格出列

这是导致问题的方法:

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TableCell";
    TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier 
                                                      forIndexPath:indexPath];

    // Configure the cell...
    int row = [indexPath row];

    Books *book = [myBooks objectAtIndex:row];
    cell.bookName.text = book.bookName;

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

完整日志:

    2014-02-05 23:19:09.458 Books[1425:a0b] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:5251
2014-02-05 23:19:09.471 Books[1425:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier TableCell - must register a nib or a class for the …

objective-c uitableview ios

4
推荐指数
2
解决办法
2万
查看次数

在以编程方式实例化的表视图控制器中注册一个单元

我收到此错误:

'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier NavigationNodeCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
Run Code Online (Sandbox Code Playgroud)

我使用两个具有相同类"NavigationItemCell"和两个标识符"NavigationNodeCell"和"NavigationLinkCell"的单元格.

我创建了一个单元格,例如:

let cell: NavigationItemCell  = self.tableView.dequeueReusableCellWithIdentifier("NavigationNodeCell",     forIndexPath: indexPath) as! NavigationItemCell
Run Code Online (Sandbox Code Playgroud)

这个问题一直存在于我之前,例如dequeueReusableCellWithIdentifier:forIndexPath中的断言失败:

据我所知(例如Sebastian Borggrewe的anser),它应该足以在故事板中注册UITableViewCell及其自定义类和标识符.

这正是我所做的,我仍然得到这个错误.我试图使用两个不同的类,但它没有解决错误.我也尝试用笔尖注册我的细胞但是我遇到了其他问题(标签是零).

我发现这个问题可能会发生,因为我以编程方式实例化了一个新的表视图控制器.

var newController = MyTableViewController()
Run Code Online (Sandbox Code Playgroud)

这是否意味着我还要注册笔尖?这是一个问题,我必须两次注册同一个班级?我如何避免nil标签的问题?

uitableview nib ios swift

1
推荐指数
1
解决办法
2276
查看次数

加载 tableView 时解包可选值时意外发现 nil

我已经在堆栈上有一段时间了,但从来不需要问一个问题,因为我总是在一些搜索后找到答案,但现在我真的被困住了。我一直在四处寻找并通过一些试验和错误来寻找答案,但我不断收到同样的错误。我基本上是在屏幕的下半部分制作一个带有 tableView 的个人资料页面。上半部分正在加载精细填充当前用户的信息。与视图控制器和单元格视图控制器的所有连接看起来都很好。但是,表视图将显示为没有数据并在加载致命错误时崩溃:

解包可选值时意外发现 nil。

我也相信cellForRowAtIndexPath根本没有被调用,因为“测试”没有打印到日志中。

我正在使用最新版本的 Swift 和 Parse。

我对 swift 比较陌生,所以我会继续在这里发布我的整个代码,并感谢任何帮助。

import UIKit
import Parse
import ParseUI

class profileViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {


@IBOutlet var tableView: UITableView!
@IBOutlet var profilePic: UIImageView!
@IBOutlet var userName: UILabel!
@IBOutlet var userBio: UILabel!
var image: PFFile!
var username = String()
var userbio = String()
var content = [String]()


@IBAction func logout(sender: AnyObject) {
    PFUser.logOut()
    let Login = storyboard?.instantiateViewControllerWithIdentifier("ViewController")
    self.presentViewController(Login!, animated: true, completion: nil)

}

override func viewDidLoad() {
    super.viewDidLoad()


    profilePic.layer.borderWidth …
Run Code Online (Sandbox Code Playgroud)

uitableview ios parse-platform swift

1
推荐指数
1
解决办法
4259
查看次数

无法使标识符为“costumeCell”的单元出列 - 必须为标识符注册笔尖或类,或者连接情节提要中的原型单元

我正在尝试创建一个简单的应用程序,但是:

'NSInternalInconsistencyException',原因:'无法使具有标识符术语的单元出列 - 必须为标识符注册笔尖或类,或者连接情节提要中的原型单元'

代码:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CostumeCellView

    cell.textLabel?.text = titles[indexPath.row]

    return cell
}
Run Code Online (Sandbox Code Playgroud)

屏幕:

班级

标识符

我不知道该怎么做。

uitableview ios swift

1
推荐指数
1
解决办法
1万
查看次数