首页 \ 问答 \ XML Writer问题(XML Writer question)

XML Writer问题(XML Writer question)

我正在使用XML Writer在我的应用程序中创建一些重要事件的日志。

目前一切正常,假设应用程序正确关闭,但如果不是,则文件未关闭且日志基本丢失。

让我们假设编写一个简单的元素,如下所示:

 writer.WriteStartElement(eventName);
 writer.WriteAttributeString("t", DateTime.Now.ToString());
 writer.WriteString(eventBody);
 writer.WriteEndElement();

有没有办法在此时关闭文件并稍后将其余元素附加到它,然后关闭根元素和xml编写器?


I'm using XML Writer to create a log of some important events in my application.

Currently it all works fine assuming that the application is correctly closed, but if it isnt, the file isnt closed and the log is basically lost.

Let's assume the writing of a simple element, something like this:

 writer.WriteStartElement(eventName);
 writer.WriteAttributeString("t", DateTime.Now.ToString());
 writer.WriteString(eventBody);
 writer.WriteEndElement();

Is there any way to close the file at this point and append the remaining elements to it later and only then closing the root element and xml writer?


原文:https://stackoverflow.com/questions/2352551
更新时间:2023-11-21 15:11

最满意答案

我看到两种实现方式:

  1. 在cellForRowAt方法中,您可以调用accessoryButton.isHidden = true或false
  2. 更优选的方式 - 用箭头图像创建您自己的自定义UIButton并将其放置在披露指示器的位置上。 并通过isHidden标志设置可见性。

I see two ways of implementing that:

  1. In cellForRowAt method you can call accessoryButton.isHidden = true or false
  2. More preferred way - create your own custom UIButton with arrow image and place it on disclosure indicator's position. And set visibility via isHidden flag.

相关问答

更多
  • 不要使用UITableViewCell的初始化程序,而是从你的笔尖加载单元格: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"EditCell"; EditCell *cell = (EditCell*) [tableView dequeueReusabl ...
  • GetCell()方法的签名已更改。 就是现在: public override UIKit.UITableViewCell GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv) { return base.GetCell (item, reusableCell, tv); } 改变的原因是支持重用细胞。 解决这些问题的最简单方法是在代码文件中键入override ,然 ...
  • 请注意, 您必须使用透明背景 这是我可以得到的最好的匹配,在photoshop文件中: 请注意,它包含作为图层的REAL iOS IMAGE(从屏幕截图),因此可以进行比较。 http://www.filedropper.com/fakearrowiosnov2013psd 看起来VBK想要UITableView集合中的单一V形。 这是所谓的“披露指标”,而不是UIButton提供的“ 细节披露”。 我想你想要这样的东西: 它是50x80与透明背景。 在按钮或UIImageView顶部使用此图像。 调整大小 ...
  • 你永远不会像这样初始化细胞。 在cellForRowAtIndexPath您调用dequeueReusableCellWithIdentifier并根据indexPath设置单元格。 如果您已在Storyboard文件中创建了单元格,请确保在故事板中设置其标识符。 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let cell = tab ...
  • 我看到两种实现方式: 在cellForRowAt方法中,您可以调用accessoryButton.isHidden = true或false 更优选的方式 - 用箭头图像创建您自己的自定义UIButton并将其放置在披露指示器的位置上。 并通过isHidden标志设置可见性。 I see two ways of implementing that: In cellForRowAt method you can call accessoryButton.isHidden = true or false Mor ...
  • 我期待披露将在新细胞内,但事实并非如此。 它是在单元格内部,但它似乎在你外面因为它是在图像外部视图。 我们需要将图像视图扩展到披露指标之下。 我做了一个简单的把领空间约束设置为负值的技巧: (以上是绿色视图的约束,在您的情况下图像!) 我还在.xib而不是代码中添加了披露指标: 在.xib它将显示如上图所示,但它在我们运行时起作用: 我没有添加图像,而是添加了绿色的UIView ,这只是为了更快地实现。 你可以用UIImageView做同样的事情。 I was expecting that disclosu ...
  • override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) { if let cell = tableView.cellForRowAtIndexPath(indexPath) as? CustemTableViewCell { // here you can access the cell and it's content } ...
  • 创建自定义单元格时,请确保将视图控制器添加为按钮操作的目标。 所以在你的视图控制器中(假设它是表视图的数据源): - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // All your standard identifier & dequeueing stuff here if (cell == nil) { ...
  • 这是一个更方便的数据源的建议 为单元格类型创建枚举 enum CellType { case one, two } CellData结构包含节的标题,单元格类型的数组和文本字符串的数组。 struct CellData { let title : String let typeArray : [CellType] let textArray : [String] } 声明数据源数组 var arrayOfCellData = [CellData]() 在viewDidL ...
  • 您不需要使用IBOutlet,因为您不想使用IB中的属性 @interface chatCell : UITableViewCell { UIImageView *homeTeamImage; UILabel *homeTeamLabel; UIImageView *awayTeamImage; UILabel *awayTeamLabel; } @property(nonatomic, weak) UIImageView *homeTeamImage; @property ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。