如何在objective-c中创建和定位新的图像视图?
谢谢!
我试过了,但它似乎没有任何作用……
-(void)drawStars{ //uses random numbers to display a star on screen
//create random position
int xCoordinate = arc4random() % 10;
int yCoordinate = arc4random() % 10;
UIImageView *starImgView = [[UIImageView alloc] initWithFrame:CGRectMake(xCoordinate, yCoordinate, 58, 40)]; //create ImageView
starImgView.image = [UIImage imageNamed:@"star.png"];
[starImgView release];
我把这个方法放在我的视图控制器中。我看到一些CG的东西,我需要导入核心图形还是什么?(核心图形到底是什么?)
发布于 2010-07-24 21:18:49
您尚未将视图作为子视图添加到另一个视图,这意味着它不在视图层次结构中。
假设您是在视图控制器中执行此操作,则可能如下所示:
[self.view addSubview: imgView];
发布于 2015-09-29 17:14:45
(void)viewDidLoad {
[super viewDidLoad];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.layer.frame.size.width, self.view.layer.frame.size.height)];
imgView.image = [UIImage imageNamed:@"emptyCart.jpeg"];
imgView.backgroundColor = [UIColor whiteColor];
imgView.contentMode = UIViewContentModeCenter;
[self.view addSubview: imgView];
}
发布于 2014-06-27 14:04:40
我在向NSString
传递值NSSArray
时遇到了问题,
我得到了答案:
//Display all images....
NSString *imgstring= [self.allimages objectAtIndex:indexPath.row];
cell.myimages.image=[UIImage imageNamed:imgstring]; //displaying Images in UIImageView..noproblem.
// Display all numbers...
cell.mylables.text=[NSString stringWithFormat:@"%@", [mysetobjectAtIndex:indexPath.row ]]; //showing results fine ArghyA..
https://stackoverflow.com/questions/3321374
复制相似问题