English 中文(简体)
Get UIImage 从方案角度看问题。
原标题:Get UIImageView programmatically from View.

我在《法典》中打造了“UIImage”语,我希望稍后再接听并树立形象。 我如何帮助?

for (int x = 1; x <= 5; x++) {
UIImageView *Game_ImageViews = [[UIImageView alloc] 
                            initWithFrame:CGRectMake(0, 0, 100, 100)];
    Game_ImageViews.tag = x;
    [Game_View addSubview:Game_ImageViews];
}


            UIImage *image = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath]      
                                                                  stringByAppendingPathComponent:@"Test.png"]];
        (UIImageView*)[self.view viewWithTag:100].image = image;
        [image release];
问题回答

viewWithTag, 如果与标签有分辨率,将给您以意见。 例如,您的<代码>本身。 必须要有100个字塔的子座。

最初,你正在设立<代码>Game_View的子目,标有1、2、3、4、5。

因此,为了找回你必须做的标子,假定你希望检索贴上<代码>1的意见:

 ((UIImageView*)[Game_View viewWithTag:1]).image = image;

还有其他几个问题值得一提。 您在座右铭中不再发布<代码>Game_ImageView,以便提供传闻。

此外,如果你使用<代码>imageNamed方法>,这将给你带来多种好处。 首先,你有可以改善业绩的焦土图。 第二,你有一个自动释放的物体,可以拯救你释放。 不管怎样,你都希望像你所做的那样,以最大的业绩和控制。





相关问题
Help with Open GL iPhone

I am trying to put an OpenGL View into my application but I want to make sure that before I do this that the view is transparent because I want to see and interact with the view behind it as well as ...

Image loads in simulator but not device?

In Interface Builder, I have a UIImageView in a nib and have selected an image from the View Attributes pane. The image loads fine in the simulator but not on my device in debug mode. I don t get ...

pixel value in UIImageView s image

I m trying to find the value of an pixel in the image displayed in an UIImageView. getting the pixel on the display is (relatively) simple. But when the image displayed is scaled (say the orgig. image ...

changing image dynamically in iPhone application

My problem is, I have table of names. And when I touch on each name, a new view should appear and image of corresponding name. For all the names only one view should be there and the image should ...

UIImageView - How to get the file name of the image assigned?

Is it possible to read the name of an UIImageView s UIImage that s presently stored in the UIImageView? I was hoping you could do something kind of like this, but haven t figured it out. NSString *...

UIImageView drifting on viewDidLoad

I am programmatically adding a UIImageView and a UILabel to multiple screens in a program I m working on. As such, I ve written a UIViewController that contains the code to load up the UIImageView ...

热门标签