小编Sta*_*lue的帖子

在scrollView中的ImageView中裁剪缩放图像

我已经从我身边做了很多努力.最后我需要帮助.谢谢

目标:1)我如何在ScrollView中使用imageView

2)如何在内部scrollView中裁剪缩放的图像.

我在Scroll View中有一个imageView.我希望缩放后的裁剪图像显示在scrollview边界内.我已经剪裁了图像,但它与我想要的完全不同.

在这里,我将backgroundColor Black设置为我的scrollView.当我在其中放置imageView时,它不合适.在此输入图像描述

滚动视图内的缩放图像后

在此输入图像描述

并且在裁剪图像之后

在此输入图像描述

我的代码在这里:

- (void)viewDidLoad
{
    [super viewDidLoad];

    CGRect frame1 = CGRectMake(50,50,200,200);

    CGRect frame2 = CGRectMake(50,50,200,200);

    imageView1=[[UIImageView alloc]initWithFrame:frame1];

   imageView1.image= [UIImage imageNamed:@"back.jpeg"];

   imageView1.backgroundColor=[UIColor brownColor];

   imageView1.contentMode = UIViewContentModeScaleAspectFit;



   scroll=[[UIScrollView alloc]initWithFrame:frame2];

   scroll.backgroundColor=[UIColor blackColor];

  [scroll addSubview:imageView1];

  scroll.delegate=self;

 [self.view addSubview:scroll];

 [self setContentSizeForScrollView];

 self.imageView1.userInteractionEnabled = YES;

}
Run Code Online (Sandbox Code Playgroud)

设置滚动视图contentSize

-(void)setContentSizeForScrollView
{
 // scroll.contentSize = CGSizeMake(imageView1.frame.size.width,imageView1.frame.size.height);

    scroll.contentSize = CGSizeMake(200, 200);
   scroll.minimumZoomScale = .50;
  scroll.maximumZoomScale = 1.5;
}
Run Code Online (Sandbox Code Playgroud)

我的作物逻辑是

-(IBAction)cropButtonClicked
{
    //Calculate the required area from the scrollview

CGRect rect = CGRectMake(50, …
Run Code Online (Sandbox Code Playgroud)

iphone crop ios

7
推荐指数
1
解决办法
6489
查看次数

构建成功但不在模拟器上运行

我从这里下载了Brad Larson的代码 .当我运行它.它显示构建成功但它不在模拟器中运行.请指导我正确的方向.

我检查app delegate文件中的方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
.......
Run Code Online (Sandbox Code Playgroud)

}

不叫.

谢谢

iphone gpu ios

2
推荐指数
1
解决办法
2816
查看次数

如何在单个循环中添加多个textField?

我想在一个循环中添加多个UITextField.当用户与UITextFields交互时识别它们.所以请帮助我.

谢谢

目前我单独放置UITextField,就像这样

txt_FirstName=[[UITextField alloc]initWithFrame:CGRectMake(framex1, framey1, framex2, framey2)];
txt_FirstName.borderStyle = UITextBorderStyleRoundedRect;
txt_FirstName.font = [UIFont systemFontOfSize:15];
txt_FirstName.placeholder = @"First Name";
txt_FirstName.autocorrectionType = UITextAutocorrectionTypeNo;
txt_FirstName.keyboardType = UIKeyboardTypeDefault;
txt_FirstName.returnKeyType = UIReturnKeyDone;
txt_FirstName.clearButtonMode = UITextFieldViewModeWhileEditing;
txt_FirstName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;    
txt_FirstName.delegate = self;
[frameView addSubview:txt_FirstName];
[txt_FirstName release];

framey1=framey1+50;

txt_MiddleName=[[UITextField alloc]initWithFrame:CGRectMake(framex1, framey1, framex2, framey2)];
txt_MiddleName.borderStyle = UITextBorderStyleRoundedRect;
txt_MiddleName.font = [UIFont systemFontOfSize:15];
txt_MiddleName.placeholder = @"Middle Name";
txt_MiddleName.autocorrectionType = UITextAutocorrectionTypeNo;
txt_MiddleName.keyboardType = UIKeyboardTypeDefault;
txt_MiddleName.returnKeyType = UIReturnKeyDone;
txt_MiddleName.clearButtonMode = UITextFieldViewModeWhileEditing;
txt_MiddleName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;    
txt_MiddleName.delegate = self;
[frameView addSubview:txt_MiddleName];
[txt_MiddleName release];
Run Code Online (Sandbox Code Playgroud)

iphone textfield ios

0
推荐指数
1
解决办法
622
查看次数

标签 统计

ios ×3

iphone ×3

crop ×1

gpu ×1

textfield ×1