- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在构建一个包含 UITableview 的应用程序。我让表格 View 可以完美工作,现在我想让单元格更具体地满足我的需求。 tableviewcell 包含图片、标题、副标题和发布日期。我认为这很简单,但我无法让它发挥作用。我尝试遵循 wrox Professional iPhone 编程单点触控(第 120 和 121 页)中的示例(和示例),但我无法让它在我的情况下工作。我尝试遵循此link还有这个link也一样,但是并没有什么卵用。当我以不同的方式做一件事时,它就会成为一个问题。
我的项目中有以下一些文件:
注意:我已经有了一个 RootViewController,但是当我为单元格创建界面时,我添加了一个部分(用于 RootViewController)来将单元格添加到其中。
这是我的代码片段:
myTableViewCell.xib.designer.cs
// Base type probably should be MonoTouch.UIKit.UIViewController or subclass
[MonoTouch.Foundation.Register("RootViewController")]
public partial class RootViewController {
private myTableViewCell __mt_Cell;
#pragma warning disable 0169
[MonoTouch.Foundation.Connect("Cell")]
private myTableViewCell Cell {
get {
this.__mt_Cell = ((myTableViewCell)(this.GetNativeField("Cell")));
return this.__mt_Cell;
}
set {
this.__mt_Cell = value;
this.SetNativeField("Cell", value);
}
}
}
// Base type probably should be MonoTouch.UIKit.UITableViewCell or subclass
[MonoTouch.Foundation.Register("myTableViewCell")]
public partial class myTableViewCell {
private MonoTouch.UIKit.UIImageView __mt_img;
private MonoTouch.UIKit.UILabel __mt_lblInfo;
private MonoTouch.UIKit.UILabel __mt_lblReleaseDate;
private MonoTouch.UIKit.UILabel __mt_lblTitle;
#pragma warning disable 0169
[MonoTouch.Foundation.Connect("img")]
private MonoTouch.UIKit.UIImageView img {
get {
this.__mt_img = ((MonoTouch.UIKit.UIImageView)(this.GetNativeField("img")));
return this.__mt_img;
}
set {
this.__mt_img = value;
this.SetNativeField("img", value);
}
}
[MonoTouch.Foundation.Connect("lblInfo")]
private MonoTouch.UIKit.UILabel lblInfo {
get {
this.__mt_lblInfo = ((MonoTouch.UIKit.UILabel)(this.GetNativeField("lblInfo")));
return this.__mt_lblInfo;
}
set {
this.__mt_lblInfo = value;
this.SetNativeField("lblInfo", value);
}
}
[MonoTouch.Foundation.Connect("lblReleaseDate")]
private MonoTouch.UIKit.UILabel lblReleaseDate {
get {
this.__mt_lblReleaseDate = ((MonoTouch.UIKit.UILabel)(this.GetNativeField("lblReleaseDate")));
return this.__mt_lblReleaseDate;
}
set {
this.__mt_lblReleaseDate = value;
this.SetNativeField("lblReleaseDate", value);
}
}
[MonoTouch.Foundation.Connect("lblTitle")]
private MonoTouch.UIKit.UILabel lblTitle {
get {
this.__mt_lblTitle = ((MonoTouch.UIKit.UILabel)(this.GetNativeField("lblTitle")));
return this.__mt_lblTitle;
}
set {
this.__mt_lblTitle = value;
this.SetNativeField("lblTitle", value);
}
}
BasicTableVIiewSource.cs
public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(this._cellIdentifier);
myTableViewCell mycell = null;
//if (cell == null)
//{
mycell = new myTableViewCell();
//NSBundle.MainBundle.LoadNib("RootViewController", _controller, null);
//_controller.myTableCell = new myTableViewCell();
//mycell = _controller.myTableCell;
//cell = new UITableViewCell(UITableViewCellStyle.Subtitle, this._cellIdentifier);
//}
//else
//{
// mycell = (myTableViewCell)cell;
//}
TrailerInfo item = this._tableItems[indexPath.Section].items[indexPath.Row];
mycell.Title = item.Title;
mycell.Info = "Genre: " + item.genre ;
mycell.ReleaseDate = Convert.ToDateTime(item.Releasedate).ToLongDateString();
mycell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
if(!string.IsNullOrEmpty(item.ImageURL))
{
mycell.myImage = item.image;
}
return mycell;
RootViewController.xib.designer.cs
// Base type probably should be MonoTouch.UIKit.UIViewController or subclass
//[MonoTouch.Foundation.Register("RootViewController")]
public partial class RootViewController {
private MonoTouch.UIKit.UITableView __mt_view;
#pragma warning disable 0169
[MonoTouch.Foundation.Connect("view")]
private MonoTouch.UIKit.UITableView view {
get {
this.__mt_view = ((MonoTouch.UIKit.UITableView)(this.GetNativeField("view")));
return this.__mt_view;
}
set {
this.__mt_view = value;
this.SetNativeField("view", value);
}
}
}
RootViewController.xib
public override void ViewDidAppear(bool some)
{
this.TableView.Source = new BasicTableViewSource(items, this);
}
正如你所见,我一直在更改代码。我不确定到底是什么问题。最近它一直告诉我属性(标题、信息、发布日期)为空。所以我假设 mytableviewcell 没有被启动(或引用)。感觉两个 RootViewControlller 部分类不能一起工作。再说一遍,这只是一种预感,我根本不知道出了什么问题。如有任何帮助,我们将不胜感激。
最佳答案
这看起来像 Button in ContentView causes crash in MonoTouch runtime. Bug in Monotouch 4.0? 的重复项
并且还在 Xamarin 的 bugzilla @ http://bugzilla.xamarin.com/show_bug.cgi?id=134 上进行跟踪
主要问题是没有任何内容引用 GetCell 返回的托管“mycell”,因此 GC(垃圾收集器)可以(并且确实)收集/释放它。也可以收集仅与单元格关联的所有内容,稍后当您点击事件处理程序时,这些内容将会崩溃。
要解决此问题,请保留您创建的单元格的引用(例如列表<>)。这将确保 GC 无法收集它们,并且其中的所有内容在需要时都将处于事件状态(例如事件处理程序)。
关于ios - Monotouch - UITableview Cell 空引用异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7311295/
cell.layoutIfNeeded() 和 cell.layoutSubviews() 和 cell.setNeedsDisplay() 方法一般有什么作用? 最佳答案 布局 subview 布置
是否可以在GXT 3.0中逐个单元地定义编辑器类型? 我需要创建一个转置表;列变成行,行变成列。在这种情况下,一列(从普通表格的角度来看)将具有不同的编辑器类型,而一行将具有相同的编辑器类型。 我正在
我的表格 View 中前 3 个单元格有一个标签,上面写着“松鼠”这个词。有没有办法做到这一点,如果 UILabel 在我的表格中的多个单元格中显示“Squirrels”,则只显示三个单元格中的第一个
让键和值相同有什么意义? JVM 会优化内存并使它们在堆中仅一份吗? 最佳答案 Map通常用于实现Set具有与背景图相同的属性。例如。如果映射是线程安全的,则相应的集合也将是线程安全的。如果 map
这个问题在这里已经有了答案: Testing for nil in Objective-C -- if(x != nil) vs if(x) (4 个答案) 已关闭 9 年前。
我用谷歌表格记录我们俱乐部的出席率。该表格链接到另一个谷歌表格,因此可以自动创建一个名字列表,并按字母顺序排序。在这张表格中,我还根据我们所做的活动,在人的名字旁边手动输入点数。。问题是,由于姓名列表
下面的代码如何工作: .Range("D4:F4").copy .cells(1,1).PasteSpecial 虽然下面不起作用: .Range("D4:F4").copy .cells(1,1)
我正在将一些值传递到 MySQL 数据库表中,我在考虑将整个 javascript 对象数组作为字符串传递是否更快,或者我是否应该根据速度将它们拆分为单元格。 例子: JavaScript 数组: v
display: table-cell; 和单元格之间的空间有问题。我希望所有单元格具有动态相同的宽度。 参见 JSFiddle "Ausstattung & Skizze" 比其他的要宽得多。有没有
我正在使用 apache poi 3.11,从 CellReference,我可以使用以下代码获取 rowIndex 和 Column Index。 CellReference cr = new Ce
我有一个带有圆形和阴影掉落单元格的 Collection View 。当单元格即将被导航栏覆盖时,单元格的阴影突然消失,而不是平滑地移出 View 。下面是代码: contentView.la
我刚开始使用 Swift 作为编程语言,但我遇到了自定义单元格的问题。 当我尝试创建自定义单元格,然后继续尝试按照我需要的方式设计它们(样式设置为自定义)时,一切看起来都不错。现在我不知道如何将特定数
目前,如果满足某些条件,我正在尝试设置一系列单元格的样式。我能够成功地将样式应用于一个单元格,但迄今为止未能成功地将其应用于一个范围。这是我所知道的有效方法: ElseIf OneA / OneC >
如果单元格 A1 为空白并且同一行中的任何单元格不为空白,我需要突出显示它。该行中的大多数单元格中都会包含公式。 最佳答案 创建一个新的条件格式,并使用这个公式: =AND($A$1="",COUNT
我确定这一定是可能的,但我找不到这样做的方法。 我有 2 列,一列带有数字,第二列带有日期。 例如: 数字日期 1 7月21日 2 7 月 22 日 3 7 月 23 日 4 7 月 24 日 5 7
我可能对范围有点困惑(我读过很多关于它的教程,但此时我不明白如何制作这个东西),无论如何,这就是我想要做的: 我有一个包含各种单元格的表格 Bla 1
宏记录器生成以下语句: Cells.Select 现在我明白,如果没有对象限定符,这会将所有单元格作为 Range 对象返回。 但是,我想知道这个语句的完全限定版本是什么? 是吗: Applicati
我知道 Range() 和 Cells() 属性是访问工作表上单元格的等效方法。但是,什么时候在这种组合中使用 Range.Cells() 是明智的呢? 我遇到了一个使用 Range("A1").Re
我有一个动态表,其中每一行都有一个文本框 (txtCantitate) 和一个按钮 (btnMinus)。在文本框中我有数量 (int) 并在按钮上单击我希望数量减少一个。在这里你有我在 table
我有两个 viewController。第一个 VC 在 tableCell 内有 collectionCell。第二个 VC 有 collectionCell,我有 swift File 和 Mod
我是一名优秀的程序员,十分优秀!