【问题标题】:image gallery using table view使用表格视图的图片库
【发布时间】:2011-04-13 05:01:48
【问题描述】:

我正在创建一个应用程序,该应用程序具有一个类似于图片库的模块。当我解析 XML 时,它会给出一些图像,比如 10,并显示在表格的行中。现在,当从表格中选择一行时,在我的下一个视图中,它应该在表格的行中显示 10 个图像的缩略图。一行应包含 4 个小图像,依此类推。

有什么好的编程建议吗?

谢谢

【问题讨论】:

    标签: iphone uitableview uiimageview


    【解决方案1】:

    使用 Three20 中的 TTThumbsViewController:
    https://github.com/facebook/three20/

    教程:
    http://mobile.tutsplus.com/tutorials/iphone/iphone-photo-gallery-three20/

    感觉很自然,完全符合您的需要:

    【讨论】:

      【解决方案2】:

      如果您不需要这些单元格的重新排序功能,那么您可以通过子类化 UITableviewCell 来实现,其中每个单元格包含 4 个按钮。内部消息可以由委托人发送。

      更新:

      自定义单元格示例:

        @protocol MyCellDelegate <NSObject>
        - (void)notifyCell:(MyCell *)cell didTouchupInside:(UIButton *)innerButton;
        @end
      
        @interface MyCell : UITableViewCell {
        @private
            // easy to understand button example
            // you can use array or dictionary to manage your buttons.
            UIButton *mButton1;
            UIButton *mButton2;
            UIButton *mButton3;
            UIButton *mButton4;
      
            // Other member variables.
        }
      
        @property (nonatomic, assign) id <MyCellDelegate> delegate;
      
        - (id)initWithReuseIdentifier:(NSString *)reuseIdentifier delegate:(id)delegate;
      
        @end
      

      通过 MyCellDelegate,客户端可以知道 MyCell 对象发生了什么。

      【讨论】:

      • 如果我想选择要在下一个视图中显示的特定图像,我该怎么做。为此我必须指定 uibutton 的哪些属性..
      • 您可以将目标和动作添加到 UIButton,并通过委托传递这些事件。您可以为此子类化单元定义自定义协议,以便通过委托发送消息。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多