小编use*_*474的帖子

绘图圆没有填充IOS

我正在使用此代码在UIImageView中绘制一个圆圈.

CAShapeLayer *circleLayer = [CAShapeLayer layer];
// Give the layer the same bounds as your image view
[circleLayer setBounds:CGRectMake(0.0f, 0.0f, [photoView bounds].size.width,
                                  [photoView bounds].size.height)];
// Position the circle anywhere you like, but this will center it
// In the parent layer, which will be your image view's root layer
[circleLayer setPosition:CGPointMake(coordsFinal.x + 130, coordsFinal.y + 200)];
// Create a circle path.
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:
                      CGRectMake(0.0f, 0.0f, 50.0f, 50.0f)];
// Set the path on the layer
[circleLayer setPath:[path CGPath]]; …
Run Code Online (Sandbox Code Playgroud)

xcode ios

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

确定UIImageView是否已旋转

我正在以这种方式旋转UIImageView:

-(IBAction)rotateImageView:(id)sender{
photoView.transform = CGAffineTransformRotate(photoView.transform, M_PI);
}
Run Code Online (Sandbox Code Playgroud)

如您所见,图像可以向上或向下.是否可以检测图像是上升还是下降,以便执行以下操作:

if(image is up)....
Run Code Online (Sandbox Code Playgroud)

objective-c ios

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

"无法检查应用程序包"Xcode

出于某种原因,我在xcode(第三方SDK)中导入了一些文件,即使应用程序构建成功,我也会收到此错误:Xcode错误消息:"无法检查应用程序包".这是什么意思?该应用程序不在真实设备上运行,但适用于模拟器IOS ...

xcode ios

7
推荐指数
3
解决办法
8988
查看次数

删除NSNotificationCenter观察者

我通过在ViewDidLoad中添加此代码来检测键盘的显示/隐藏:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(keyboardDidHide:) 
                                             name:UIKeyboardDidHideNotification 
                                           object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(keyboardWillShow:) 
                                             name:UIKeyboardWillShowNotification 
                                           object:nil];
Run Code Online (Sandbox Code Playgroud)

在某些时候,我想删除这些观察者,而不是打电话

 [[NSNotificationCenter defaultCenter] removeObserver:self];
Run Code Online (Sandbox Code Playgroud)

因为这会删除所有观察者,我还有其他观察者,我不想删除它们.我怎么才能删除那两个?

objective-c nsnotifications nsnotificationcenter ios

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

使用Core Animation更改cornerRadius

我试图通过以下方式更改按钮的角半径(OpenNoteVisible.layer):

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
animation.timingFunction = [CAMediaTimingFunction     functionWithName:kCAMediaTimingFunctionLinear];
animation.fromValue = [NSNumber numberWithFloat:10.0f];
animation.toValue = [NSNumber numberWithFloat:0.0f];
animation.duration = 1.0;
[animation.layer setCornerRadius:140.0];
[OpenNoteVisible.layer addAnimation:animation forKey:@"cornerRadius"];
Run Code Online (Sandbox Code Playgroud)

但是这段代码在行[animation.layer setCornerRadius:140.0]上给出了一个错误; 我不明白为什么.我已经导入了Quartz核心框架.

core-animation core-graphics ios

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

在UIImageView IOS中绘制形状

我试图在UIImageView中使用特定图像绘制一些圆圈.这就是我想要做的事情:

UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(contextRef, 2.0);
CGContextSetStrokeColorWithColor(contextRef, [color CGColor]);
CGRect circlePoint = (CGRectMake(coordsFinal.x, coordsFinal.y, 50.0, 50.0));

CGContextStrokeEllipseInRect(contextRef, circlePoint);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[photoView addSubview:image];
Run Code Online (Sandbox Code Playgroud)

圆圈绘制得很好,但我希望PhotoView充当它的遮罩.因此,例如,如果我使用动画将UIImageView移出UIView,我希望圆圈随之移动.重要的是坐标相对于整个屏幕.

xcode ios

6
推荐指数
1
解决办法
1万
查看次数

限制应用程序仅在4英寸设备上运行IOS

我正在为iphone创建一个ios应用程序.我想让它只在4英寸设备上运行(所以iphone 5和iPod touch 5).当我在其中一个上运行它时,工作正常.但是当我在ipad上运行时,会出现X2按钮,而ipad会模拟旧的3.5英寸显示屏,而不是4英寸显示屏.为什么?

ios

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

使用UISearchBar搜索表视图

我正在使用此代码搜索UItableView:

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {



if(searchText.length == 0)
{
    isFiltered = FALSE;
}
else
{
    isFiltered = TRUE;


    if (filteredTableData == nil)
       filteredTableData = [[NSMutableArray alloc] init];
    else 
        [filteredTableData removeAllObjects];

    for (NSString* string in self.itemArray)
    {
        NSRange nameRange = [string rangeOfString:searchBar.text options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)];
        if(nameRange.location != NSNotFound)
        {
            [filteredTableData addObject:string];
        }
    }
}
[tableView reloadData]; 
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
}
Run Code Online (Sandbox Code Playgroud)

一切正常,但如果我按下开始编辑时出现的取消按钮,我的列表不会回来,但搜索结果仍然存在.要显示列表,我必须开始输入,甚至是搜索栏中的单个字符,然后将其删除或按"x"查看所有列表.有办法阻止取消按钮吗?或者在按下时显示列表?

xcode ios

4
推荐指数
1
解决办法
1万
查看次数

在UIBarButtonitem类型的对象上找不到属性层

我试图将此动画应用于UIBarButtonItem:

CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
    theAnimation.duration=1.0;
    theAnimation.repeatCount=HUGE_VALF;
    theAnimation.autoreverses=YES;
    theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
    theAnimation.toValue=[NSNumber numberWithFloat:0.5];
    [plusbutton.layer addAnimation:theAnimation forKey:@"animateOpacity"];
Run Code Online (Sandbox Code Playgroud)

但是我在最后一行代码的标题中报告了错误.如何访问barbuttonItem的图层?

ios

4
推荐指数
1
解决办法
1829
查看次数

在UIScrollView中获取UItextField的真实位置

我在UIscrollview中有一系列UItextViews。文本视图的数量取决于用户,可以有他想要的数量。

我将相同的UItapGestureRecogniser分配给每个UItextView(添加到NSMutableArray中)。轻按UItextView时,将绘制一条线,将textField连接到用户在屏幕上触摸的点。一切正常,除了当我向下滚动时,我以这种方式设置的起点的y坐标不正确:

CGPoint coords;
coords.y = textname.frame.origin.y + 15;
Run Code Online (Sandbox Code Playgroud)

...其中文本名是手势的发送者

有没有一种方法可以获取实际屏幕的坐标,而无需考虑UItextView在UIscrollView中?

xcode ios

3
推荐指数
1
解决办法
2266
查看次数