English 中文(简体)
为什么我的原型细胞是空白的?
原标题:Why do my prototype cells show up blank?

在我的故事框中的直观视图中,我定义了一个原型单元格。在这个单元格中(一个自定义的 kzTexturedCellv2 类),我有一个文字视图和一个图像视图。我还给该单元格一个标识符(“kzTexturedCellv2 ”),并使用了

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

kzTexturedCellv2 *cell = [[kzTexturedCellv2 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"kzTexturedCellv2"];

...

创建单元格。 问题在于单元格显示为空白( 不包括我在故事中添加的任何子视图 ) 。 当我试图在单元格中设置外观文本时, 它总是返回空。 这里发生了什么?

最佳回答

当使用记事本时, 不需要对单元格进行分解 。

dequeueRecrete-可使用性细胞行为因原型单元格而改变?

只使用 :

kzTexturedCellv2 *cell = [tableView dequeueReusableCellWithIdentifier:@"kzTexturedCellv2"];

Alloc init 将由框架处理

问题回答

你能看到下面的代码吗? 我希望它能对你有所帮助

- (void)viewDidLoad{
[super viewDidLoad];

// Create your image
UIImage *image = [UIImage imageNamed: @"person_menu.png"];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc]
                              initWithImage:image
                              style:UIBarButtonItemStylePlain
                              target:nil
                              action:nil];
// set the text view to the image view
self.navigationItem.leftBarButtonItem = barButton;

menuItems = @[@"title", @"Payment", @"History",@"BookNow",@"Help", @"Promotions",@"Notifications", @"Settings", @"logOut"];
}
#pragma mark
#pragma mark - UITableViewDelegate Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
// Return the number of sections.
return 1;
}

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// Return the number of rows in the section.
return [menuItems count];
}
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
    return 140;
}else{
     return  75;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CellIdentifier = [menuItems objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.highlighted = YES;
return cell;
}

在 UITableviewCell 中你拥有的标识符, 你永远可以收集这些识别符, 并将其添加到一个 NSARRRR 中 。

对于您来说,您可以这样使用:

kzTexturedCellv2 *cell = [tableView dequeueReusableCellWithIdentifier:@"kzTexturedCellv2"];




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签