【发布时间】:2012-05-14 13:37:05
【问题描述】:
您好,我是 iPhone Xcode 开发的新手,一直坚持实现历史功能。
用外行的话我有
4 个按钮(每个按钮都有自己独特的图像)
(按钮 1) (按钮 2) (按钮 3) (按钮 4)
和 5 个图像视图
(图像视图位置 1) (图像视图位置 2) (图像视图位置 3) (图像视图位置 4) (图片浏览位置 5)
每次单击按钮(最多 5 次)时,我都需要将其显示在适当的图像视图中。
即如果首先按下按钮 4,它将显示在图像视图 1 中 如果第二次按下按钮 3,它将显示在图像视图 2 等处。
我非常感谢一些帮助或朝着正确的方向前进。
提前致谢
更新代码:
viewcontroller.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
IBOutlet UIImageView *imageview_history_1;
IBOutlet UIImageView *imageview_history_2;
IBOutlet UIImageView *imageview_history_3;
IBOutlet UIImageView *imageview_history_4;
IBOutlet UIImageView *imageview_history_5;
}
// I would think this could be consolidated into one function
-(IBAction)showhistory_1;
-(IBAction)showhistory_2;
-(IBAction)showhistory_3;
-(IBAction)showhistory_4;
-(IBAction)showhistory_5;
@end
#import ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
// function to add to history
// Need an if/for statement???
// On button event 1 display result at image view_history 1,
// On button event 2 display result at image view_history 2.
- (IBAction)showhistory_1 {
UIImage *img = [UIImage imageNamed:@"button1"];
[imageview_history_1 setImage:img];
}
@end
//我一直在创建函数。再次感谢。
【问题讨论】:
-
一般来说,为这类问题包含一些代码是个好主意,这样我们就知道你在哪里以及我们需要带你去哪里。
-
嗨@RyanPoolos 希望更新后的代码有助于理解我想要实现的目标。再次感谢。
-
并且不要使用这样的帖子标题,因为该标题不适合这个问题。
标签: iphone xcode ios4 uiimageview xcode4.2