English 中文(简体)
我如何读到美国国家银行的一条可读的电文高?
原标题:How do I read a UITableViewCell (subclass) s height from a NIB?
  • 时间:2011-11-22 09:00:27
  •  标签:
  • ios

我在一家美国银行中定义了一条可调用的电文。 在“国家银行一号”中,我把框架的高度定为183,我还将“Row Height”设定为183,并贴出习俗。

在我的原始问题中,所有这一切都是错误的。 它像我所看到的那样, height上了错误的高度,而囚室被装在错误的高度上,后来又被重新sized到成为新陈像的右高。

在现实中,我做了一些 st的 st子(总是回到错误的高度),在晚上,我太晚才看到它,因此我要求SO提供帮助并去睡觉。 睡觉(+coffee)表明一切情况。

So for the record, if you load your custom UITableViewCell from a NIB you can look at frame.size.height and the right number comes back.

如果你从<条码>中退回错数:helsForRowAtIndexPath: 至少如果巡回囚室是表上最后的囚室,你可以找到这个灯光(我预计问题会以另一种方式出现于其他囚室)。

So I ve solved my own problem, and hopefully left enough info for anyone else who hits this. If anyone thinks this ought to have an official answer rest assured I plan on accepting the best looking one in a day or 3.

最佳回答

First UITableViewDelegate method, which gets called is heightForRowAtIndexPath not the UITableViewDataSource method, cellForRowAtIndexPath.

你们只能到“ForRowAtIndexPath”的囚室,在那里,你全心全意。 因此,它 t取了这里的习俗细胞高度。

It will take the height for the cell which is mentioned in heightForRowAtIndexPath method only. As it gets called first.

问题回答

You can use this example code to get cell height from NIB

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return [[[[NSBundle mainBundle] loadNibNamed:@"ELConvCurListViewCell" owner:self options:nil] objectAtIndex:0] bounds].size.height;
}

<>Update: 可在<代码>viewDidLoad到cellH 8,变量和上获得并分配国家银行的高度。 使用<条码>





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...