小编Jon*_*han的帖子

我的自我观点有错误的尺寸

我的观点有错误的维度.我正在运行景观,但视图报告纵向尺寸"查看宽度= 768.000000高度= 1024.000000"任何想法如何解决?我玩过我试过的自转器

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

它在视图上看起来很好,但尺寸确实与我的应用程序混乱.

autosize uiview autorotate ios

8
推荐指数
1
解决办法
3077
查看次数

来自图像的UIBezierPath

我有几个与此类似的png文件:

在此输入图像描述

一切都是透明的,但黑色的道路.我想要做的是从非透明部分创建一个UIBezierPath.

编辑:所以我在考虑用png创建一个掩码然后从掩码转到UIBezierPath.那会有用吗?

再次编辑:我找到了解决方案,看看我的答案.

image-processing objective-c uiimage ios uibezierpath

5
推荐指数
1
解决办法
3398
查看次数

拖出屏幕时弹回UIImageView

我需要的是当UIImageView被拖离屏幕时它会在松开时反弹回来.我让它在左侧和上侧工作这就是我正在做的事情.

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {          

        if (!CGRectContainsPoint(self.view.frame, imageView.frame.origin)){  

            CGFloat newX = 0.0f;
            CGFloat newY = 0.0f;

            // If off screen upper and left

            if (imageView.frame.origin.x < 0.0f){
                CGFloat negX = imageView.frame.origin.x * -1;
                newX = negX;
            }else{
                newX = imageView.frame.origin.x;
            }

            if (imageView.frame.origin.y < 0.0f){
                CGFloat negY = imageView.frame.origin.y * -1;
                newY = negY;
            }else{
                newY = imageView.frame.origin.y;
            }


            CGRect newPoint = CGRectMake(newX, newY, imageView.frame.size.width, imageView.frame.size.height);

            [UIView beginAnimations:@"BounceAnimations" context:nil];
            [UIView setAnimationDuration:.5];
            [letterOutOfBounds play];
            [imageView setFrame:newPoint];

            [UIView commitAnimations];

        } …
Run Code Online (Sandbox Code Playgroud)

objective-c uiimageview uitouch ios

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

比较具有不同顺序的字符串

我有一个比较字符串的if语句,但我想比较具有相同单词但顺序不同的字符串并将其返回为true.

字符串1a,b,c

string 2 b,c,a

如何比较它们并让if语句将其视为相同的字符串?

objective-c ios

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

在Array中拖动多个UIImageViews

这就是我到目前为止所拥有的

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];

    for (UIImageView *imageView in _imageViewArray) {
            CGPoint Location = [touch locationInView:touch.view];
            imageView.center = Location;
    }   
}
Run Code Online (Sandbox Code Playgroud)

我面临的问题是,当我移动一张图像时,它们都会跳到同一个地方.

感谢cyberpawn这就是我所做的让它发挥作用

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];

    CGPoint oldPoint = [touch previousLocationInView:touch.view];
    CGPoint newPoint = [touch locationInView:touch.view];

    CGPoint diff = CGPointMake(newPoint.x - oldPoint.x, newPoint.y - oldPoint.y);

    for (UIImageView *imageView in _imageViewArray) {
        if (CGRectContainsPoint(imageView.frame, newPoint)) {
            CGPoint cntr = [imageView center];
            [imageView setCenter:CGPointMake(cntr.x + diff.x, cntr.y …
Run Code Online (Sandbox Code Playgroud)

drag-and-drop objective-c touch uiimageview ios

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