【发布时间】:2015-10-08 06:28:35
【问题描述】:
我希望将图像从 UIImageView 复制到 UIView。
我已经为 UIImageView 编写了滑动手势来选择图像,并且需要知道当用户单击添加按钮时如何将多个图像从 UIImageView 复制到 UIView。我希望用户能够将不同的图像复制到 UIView 中。稍后我会安排的。
- (IBAction)handleSwipe:(UIGestureRecognizer *)sender {
//NSLog(@"swipe");
NSArray *images=[[NSArray alloc] initWithObjects:
@"all_LE2_Series_capacitor.jpg",
@"all_LE2_Series_inductor.jpg",
@"all_LE2_Series_msline.jpg",
@"all_LE2_Series_resistor.jpg",
@"all_LE2_Short_stub.jpg", nil];
UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *) sender direction];
switch (direction){
case UISwipeGestureRecognizerDirectionLeft: imageIndex++;
break;
case UISwipeGestureRecognizerDirectionRight: imageIndex--;
break;
default:
break;
}
imageIndex = (imageIndex < 0) ? ([images count] -1):
imageIndex % [images count];
imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];
}
- (IBAction)Add:(UIButton *)sender {
dropTarget.center = imageView.center;
[self.view addSubview:dropTarget];
}
界面设计
【问题讨论】:
-
你是什么意思:“将图像从
UIImageView复制到UIView并附加值”? -
哪个附加值?
标签: ios objective-c uiview uiimageview