查看不会更新的图像(iPhone应用程序) [英] View wont update image(iphone app)

查看:38
本文介绍了查看不会更新的图像(iPhone应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的UIView * myView,其设置如下

I have a simple UIView *myView which is set as follows

myView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", r]];

这将获取索引r并获取该图像,所有这些都可以在我的两个IBAction方法中正常工作

this takes the index r and gets that image, all works correctly in my two IBAction methods

-(IBAction) previousImageSelector{
if (r != 0)
    r = r - 1;
NSLog(@"r is%d",r);
myView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", r]];

}

我目前允许用户使用输入的标题将图片保存到他们的收藏夹列表中.这一切都可以正常工作,图像的名称和索引号保存到mutableArray,当用户选择表项时出现麻烦.

I am currently allowing the user to save a picture to their favorites list with a title they input. This all works correctly, the name and index number of the image save to a mutableArray, The trouble comes when the user selects the table item.

我的应用正确检索图像的索引,将索引设置为该索引,然后调用

My app retrieves the index of the image correctly, sets the index to that and then calls the

myView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", r]];

但是由于某种原因,它不会更新视图,只会更新计数器,然后,如果用户选择下一个或上一个图像,则加载当前计数器(应加载的图像)之后的图像.

but for some reason this doesnt update the view, only the counter, and then if the user selects next or previous image the image after the current counter(the image which should have loaded) loads.

是否有刷新方法或以其他方式设置它的方法?

Is there a refresh method or a way to set it differently?

我不明白为什么下一个和上一个图像IBAction中都可以使用相同的方法,但是一旦选择了表行就不能使用这种方法.

I dont understand why the same method works in the next and previous image IBActions, but not once a table row is selected.

请咨询

致谢

推荐答案

您将 myView.image = [UIImage imageNamed ... "代码放在哪种方法中?

In which method did you put your myView.image = [UIImage imageNamed... code?

可能您需要做的是:

myView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", r]];
[myView setNeedsDisplay];

这告诉核心动画使用当前数据(即,您刚刚设置的新图像)重绘视图.

This tells the Core Animation to redraw the view with the current data (ie, the new image that you just set).

这篇关于查看不会更新的图像(iPhone应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆