我正在尝试将文本视图放在特定大小的图像视图上,但是当我从照片库中加载图像时,我的文本视图会被覆盖,我无法在其上书写。我想,当我为bi创建一个矩形框架时,来自图库的图像会覆盖到文本视图。我该怎么办?
回答:这是工作的时间:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // set image emailImage1 = [info objectForKey:UIImagePickerControllerOriginalImage]; //bi.image = [info objectForKey:UIImagePickerControllerOriginalImage]; image = [info objectForKey:UIImagePickerControllerOriginalImage]; bi = [[UIImageView alloc ] initWithImage: image ]; bi.frame = CGRectMake(20.0f, 100.0f,260.0f, 285.0f); [self.view addSubview: bi]; [self.view bringSubviewToFront:scroll]; [[picker parentViewController] dismissModalViewControllerAnimated:YES]; [picker release]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { // release picker [[picker parentViewController] dismissModalViewControllerAnimated:YES]; [picker release]; }
帮助PLZ
答案 0 :(得分:1)
bi
添加为子视图,如下所示:
[self.view addSubview: bi ];
这是对的。但是从UIView的实践看这个:
添加后,此视图会显示在任何其他子视图的顶部。
请尝试以下
[self.view insertSubview: bi belowSubview: YourTextView];
将'YourTextView'替换为指向textview的指针。它应该工作。
Sandro Meier
答案 1 :(得分:0)
语法为[self.view bringSubviewToFront:yourTextView];