Tag: uiimageview

为什么UIImageView不会更改为一次设置的其他图像?

我的代码 UIImage *img = [UIImage imageWithCGImage:[repr fullResolutionImage]]; [_photoPreview setImage:img]; 第一次正常工作。 但是,当我想更新_photoPreview中的图像时,它不会这样做,并保留原始图像。 我有一个模糊的怀疑,这是当接口被加载或什么的,但我可能是完全错误的。 任何帮助将不胜感激。

iOS拖放到具有子类的另一个视图

我有一个带有UIScrollView(boardScrollView)的RootViewController。 这有一个UIImageView作为子视图来创build一个板(boardImage)。 我可以放大和缩小,工作正常。 也滚动工作正常! 现在,我想拖放其他UIImageViews(Tiles)进出ScrollView。 我已经将UIImageView分类为TileImageView,并将方法touchesBegan,touchesMoved和touchesEnded重写。 拖放工作正常在超视图。 但是我希望能够在RootViewController上的一个IBOutlet的ScrollView上放置Tiles。 我可以拖放瓦片,因为我可以使用superview但是我不知道如何将瓦片添加到boardScrollView。 任何人都知道如何从子类访问RootViewController上的对象? 我应该委托一些东西? 或者设置不同的参数? 代码RootViewController: @implementation RootViewController_iphone @synthesize boardScrollView; @synthesize dragObject; @synthesize boardImage; – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. self.boardScrollView.clipsToBounds = YES; UIImage *image = [UIImage imageNamed:@"greyblue_numbered_15x15_900x900.png"]; self.boardImage = [[UIImageView alloc] initWithImage:image]; self.boardImage.frame = (CGRect){.origin=CGPointMake(0.0f, 0.0f), […]

iOS:如何dynamic添加图像到父视图?

我在屏幕上有一个主要的图像,并有一个“覆盖”UIView放在它的顶部,背景颜色设置为清除颜色。 我想dynamic地在覆盖视图内放置其他图像,如下所示: UIImage* m_icon = [[UIImage alloc]initWithContentsOfFile:@"icon.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:m_icon]; [m_OverlayView addSubview:imageView]; 但是图标图像没有显示出来。 我错过了什么?

使用CGContextRef在大尺寸图像上绘制线条后,在iPad中接收内存警告

我使用CGContextRef在UIImage上绘制线条。我的图像像3000×4500这样的分辨率非常大。如果绘制一条线,它不会给我记忆警告,但是如果我绘制多条线,那么会给出内存警告,之后我的应用程序崩溃。试图释放CGContextRef对象,但得到一个错误。 我的代码: UIGraphicsBeginImageContext(imageView.image.size); [imageView.image drawAtPoint:CGPointMake(0, 0)]; context2=UIGraphicsGetCurrentContext(); for(int i=0; i<kmtaObject.iTotalSize; i++) { kmtaGroup=&kmtaObject.KMTA_GROUP_OBJ[i]; //NSLog(@"Group # = %d",i); for (int j=0; j<kmtaGroup->TotalLines; j++) { lineObject=&kmtaGroup->Line_INFO_OBJ[j]; // NSLog(@"Line # = %d",j); // NSLog(@"*****************"); x0 = lineObject->x0; y0= lineObject->y0; x1= lineObject->x1; y1= lineObject->y1; color= lineObject->Color; lineWidth= lineObject->LinkWidth; lineColor=[self add_colorWithRGBAHexValue:color]; linearColor=lineColor; // Brush width CGContextSetLineWidth(context2, lineWidth); // Line Color […]

从UIImageView中删除行

我在UIImageView上绘制了一条直线。 现在,如果用户点击它,我想要删除那条线。 这是我在图像上画一条线的代码。 – (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { CGPoint location=[sender locationInView:imageView]; CGPoint contextLocation = CGPointMake(location.x*imageView.image.size.width/imageView.frame.size.width, location.y*imageView.image.size.height/imageView.frame.size.height); UIColor * linearcolor=[UIColor blueColor]; CGSize imagesize=imageView.image.size; UIGraphicsBeginImageContext(imageView.image.size); [imageView.image drawAtPoint:CGPointMake(0, 0)]; CGContextRef context=UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGPoint location2=CGPointMake(300, 400); CGContextBeginPath(context); CGContextMoveToPoint(context, contextLocation.x, contextLocation.y); CGContextAddLineToPoint(context, location2.x, location2.y); CGContextAddQuadCurveToPoint(context, contextLocation.x, contextLocation.y, location2.x, location2.y); CGContextSetLineCap(context, kCGLineCapRound); if([removeLine isEqualToString:@"true"]) { CGContextClearRect […]

如何在全屏显示图像的滚动视图?

我实现了一个方法来显示黑色背景的全屏图像。 我想适应它的图像滚动视图。 用户应该能够在全屏模式下滚动并转到下一个图像。 我怎样才能做到这一点? 这是全屏显示UIImageView的代码。 这是工作。 – (void)setUserPictImageViewZoomed:(BOOL)zoom animated:(BOOL)animated { UIView *blackView = [self.view viewWithTag:128]; BOOL isZoomed = blackView != nil; // if our current state (isZoomed) matches the desired state (zoomed), then we're done if (isZoomed == zoom) return; NSTimeInterval duration = (animated)? 0.3 : 0.0; if (zoom) { blackView = [[UIView alloc] initWithFrame:self.view.frame]; […]

如何以编程方式更改UIButton内的UIImageView的图像?

我用UIImageView和UILabel创build了一个UIButton,通过Tim的这个问题和答案的帮助,现在我想改变button点击事件的UIImageView的图像。 我试过[sender.imageView setImage:image]但它不工作

select的图像不会加载在ios 7中的自我图像查看器

我正在使用EGOPhotoViewer加载一堆来自s3的图像。 它们在表格视图中以缩略图的forms显示,所以当用户点击第五行图像时,它将图像从20开始加载到图像查看器中。 这在ios 6中运行正常。 但是当我安装ios 7并运行我的app.i有一个错误。 它无法加载点击的图像。 当用户点击图像的第5行时,图像查看器会从20开始加载第一个图像。 我正在使用这么多的代码。 – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { …… [self showSelectedPhoto:indexPath]; …… } //load the selected image -(void)showSelectedPhoto:(NSIndexPath *)indexPath { [UserInfo sharedInfo].Path=indexPath; NSLog(@"%@",indexPath); NSString *passingImageName=[[self.tableDataSource objectAtIndex:indexPath.row]objectForKey:@"fileName"]; NSMutableArray *photoArray=[self getFilteredArray]; NSMutableArray *urlsArray=[[NSMutableArray alloc] init]; // [self.tableView reloadData]; for (NSString *string in photoArray) { NSLog(@"String Values:%@",string); NSURL *imageUrl=[self getEnlargedImageImageUrl:[self._prefix stringByAppendingString:string]]; […]

如何检测2个UIViews之间的碰撞

我有一个UIImageView包含我的主要字符,我已经使UIImageView出现圆圈见下面的代码创build我的性格 copter = [[UIImageView alloc] initWithFrame:CGRectMake(100, 500, 90, 90)]; [copter setContentMode:UIViewContentModeScaleAspectFit]; copter.layer.cornerRadius = roundf(copter.frame.size.width/2.0); copter.layer.masksToBounds = YES; [copter startAnimating]; [[self view] addSubview:copter]; [self setBat:copter]; 我在我的angular色和游戏中的其他物体之间发生碰撞时遇到了麻烦。 在矩形而不是圆上检测到碰撞。 我到处寻找答案来解决这个问题,但没有运气。 这是我使用的碰撞代码: self.batVelocity += [link duration]*FBDownardBatAccelerationIpad; [[self copter] setFrame:CGRectOffset([[self copter] frame], 0, [self batVelocity])]; UIView *removeBlock = nil; for (UIView *block in [self blocks]) { [block setFrame:CGRectOffset([block frame], [link […]

使用延迟加载在滚动视图上加载图像

我正在一个应用程序中,我需要在滚动视图中加载近211个图像。 我正在做的是我将图像转换为二进制格式(NSData)并将其保存在核心数据中。 然后检索它们并在scrollview上填充它们。 它确实有效,但是有时它会抛出“内存警告”。 我了解到,懒加载是实现这一目标的一种方法。 但是,我并不完全知道它是如何完成的。 就像在当前滚动视图中可见的图像的前面/后面加载3或5个图像一样。 任何波特能帮助我一个简单的例子,这将帮助我从头开始理解? 并指出我在正确的方向。 感谢您的时间。