小编Mun*_*ndi的帖子

解雇UIAlertController(最佳实践)

当像这样使用UIAlertController时:

var alert = UIAlertController(title: "Core Location", 
     message: "Location Services Disabled!", 
     preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, 
     handler: nil))
self.navigationController.presentViewController(alert, animated: true, 
     completion: nil)
Run Code Online (Sandbox Code Playgroud)

我注意到警报视图的解雇似乎是自动完成的.不应该通过委托调用呈现ViewController来解雇呈现的 ViewController吗?

delegates ios swift

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

iCloud同步Ubiquity错误

我在我的应用程序和同步工作中集成了iCloud,但有时我收到此错误:

+[PFUbiquityTransactionLog loadPlistAtLocation:withError:](324): CoreData: Ubiquity:  
Encountered an error trying to open the log file at the location: <PFUbiquityLocation: 
0x1993c0>: /private/var/mobile/Library/Mobile Documents/ ...
Error: Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. 
(Cocoa error 256 - The item failed to download.)"

-[PFUbiquityTransactionLog loadComparisonMetadataWithError:](220): CoreData: Ubiquity:  
Error encountered while trying to load the comparison metadata for transaction log: 
<PFUbiquityTransactionLog: 0x1a3d60>
transactionLogLocation: <PFUbiquityLocation: 0x1993c0>: /private/var/mobile/Library/Mobile Documents/
transactionNumber: (null)

Error: Error Domain=NSCocoaErrorDomain Code=134302 "The operation couldn’t be completed. 
(Cocoa error 134302.)" UserInfo=0x1a50e0 {reason=Error during …
Run Code Online (Sandbox Code Playgroud)

ios icloud

9
推荐指数
1
解决办法
5743
查看次数

应用程序文档文件夹中的UIWebView图像无法刷新

我有一个UIWebView,我通过它显示动态生成的HTML

[_webView loadHTMLString:htmlString baseURL:applicationDocumentsDirectory];
Run Code Online (Sandbox Code Playgroud)

HTML包含诸如的图像<img src="chart1.png">.每次生成HTML时,图像也都是新生成的.(我已经检查过它们确实位于正确的位置并进行了更新.)但是,在第一次运行后,如果我更改数据并重新启动我的UIWebView,它将使用旧图像.

我试过了:

[[NSURLCache sharedURLCache] removeAllCachedResponses];
Run Code Online (Sandbox Code Playgroud)

无济于事.(也许并不奇怪,因为这与NSURLRequests相关.)

我知道有绝对URL的可能性,但我没有尝试过这看起来很麻烦,我希望它能够使用这些简单的相对URL.问题不是找到图像,而是适当地更新它们.

我也知道,你可以发明一些方案欺骗浏览器,以为该图像是通过改变动态src喜欢的东西chart1.png?1234在数量是随机生成的,并始终是唯一的.对于一个应该易于解决的问题,这似乎也是一种无用的解决方法.

有任何想法吗?

iphone image uiwebview ipad ios

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

UITableview重新加载SectionHeader而不是部分中的单元格

我有一个tableview,我想重新加载(并更改高度)sectionHeader而不是本节内的单元格.我想这样做的原因是因为我在标题上使用淡入淡出动画,如下所示:

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0]   
    withRowAnimation:UITableViewRowAnimationFade];
Run Code Online (Sandbox Code Playgroud)

但与此同时,我在该部分添加了一个单元格

[self.tableView insertRowsAtIndexPaths:
    @[[NSIndexPath indexPathForRow:0 inSection:0]]
    withRowAnimation:UITableViewRowAnimationRight];
Run Code Online (Sandbox Code Playgroud)

我希望能够保留UITableViewRowAnimationRight正在添加的单元格,但是当我重新加载Section时,淡入淡出动画会应用到整个部分.有没有办法只重新加载sectionHeader,而不是部分中的单元格?

iphone cocoa-touch objective-c uitableview ios

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

将圆角应用于使用UIBezierPath创建的弧

我正在使用UIBezierPath创建的循环进度条.进度条如下图所示:

在此输入图像描述

我的问题是:如何使圆弧的边缘变圆而不是矩形?

我用来绘制弧线的代码如下:

 // Draw the arc with bezier path
        int radius = 100;

        arc = [CAShapeLayer layer];
        arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:M_PI endAngle:M_PI/150 clockwise:YES].CGPath;
        arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
                                    CGRectGetMidY(self.view.frame)-radius);
        arc.fillColor = [UIColor clearColor].CGColor;
        arc.strokeColor = [UIColor purpleColor].CGColor;
        arc.cornerRadius = 0.5;
        arc.lineWidth = 6;

        [self.view.layer addSublayer:arc];

        // Animation of the progress bar
        drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
        drawAnimation.duration            = 5.0; // "animate over 10 seconds or so.."
        drawAnimation.repeatCount         = 1.0;  // Animate only once..
        drawAnimation.removedOnCompletion = YES;   // Remain stroked …
Run Code Online (Sandbox Code Playgroud)

objective-c uibezierpath

8
推荐指数
2
解决办法
2574
查看次数

UIModalPresentationStyle.FormSheet始终在iPad上全屏(SWIFT)

我正在尝试将一些Objective-C代码翻译成SWIFT.

我正在加载一个UIViewController作为表单.这是objective-c中的代码:

generalPopup.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
generalPopup.modalPresentationStyle = UIModalPresentationFormSheet;
Run Code Online (Sandbox Code Playgroud)

这是Swift中的代码:

generalPopup.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
generalPopup.modalPresentationStyle = UIModalPresentationStyle.FormSheet
Run Code Online (Sandbox Code Playgroud)

在Objective-C中,视图显示为FormSheet.在swift中,CoverVertical被维护,但视图占据整个屏幕而不是显示为FormSheet.

提醒一下,据Apple称,FormSheet是:

一种视图演示样式,其中所呈现视图的宽度和高度小于屏幕的宽度和高度,并且视图以屏幕为中心.如果设备处于横向方向且键盘可见,则向上调整视图的位置以使视图保持可见.所有未覆盖的区域都是灰色的,以防止用户与它们进行交互.

objective-c uiviewcontroller uimodalpresentationstyle presentviewcontroller swift

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

蒙面UIView,CALayer的动画

我试图实现以下目的:用户点击一个视图,一个圆形视图弹出到它的左侧,其中包含一些图像内容.视图应该从触摸点开始到触摸视图之外和左侧的最终帧的动画.在动画期间,它应该是一个圆圈,增长到正确的位置和大小

所有这些都适用于下面的代码,只是在动画期间,圆形边界仅在左侧.这就像CALayer形状滑入其最终框架.

看起来有点像这样.

在此输入图像描述

动画完成后,我会按预期完整的圆圈.

CGFloat w = 300;
CGRect frame = CGRectMake(myX, myY, w, w);
CGPoint p = [touch locationInView:self.imageView];
CGRect initialFrame = CGRectMake(p.x, p.y, 0,0);
UIImageView *circle = [[UIImageView alloc] initWithFrame:frame];
circle.image = [UIImage imageNamed:@"china"];
circle.contentMode = UIViewContentModeScaleAspectFill;
circle.backgroundColor = [UIColor clearColor];
circle.layer.borderWidth = 1;
circle.layer.borderColor = [UIColor grayColor].CGColor;
circle.layer.masksToBounds = YES;

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGRect maskRect = CGRectMake(0, 0, w, w);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddEllipseInRect(path, nil, …
Run Code Online (Sandbox Code Playgroud)

iphone animation calayer ipad ios

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

为什么即使在api控制台上我也没有在tumblr中未经授权?

这是在示例输出(目标c)中写的:

{"meta":{"status":401,"msg":"未授权"},"回复":[]}

可能是什么问题呢?

tumblr

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

如何防止NSFetchedResultsController在控制器消失时更新tableview?

I have a UITabbar with multiple controllers in it. One of the controllers is used to add Events to Core Data, while another controller is used to display events as in a UITableView using NSFetchedResultsController.

Here's the behaviour that I would like to achieve: Upon disappearing, the UITableView stops updating, and when the user comes back, the entire table view is reloaded. Otherwise, inserting events from the other controller takes longer, as new rows are created in the UITableView …

iphone core-data objective-c nsfetchedresultscontroller ios

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

为什么这种自动布局规范不够用?

我试图摆脱Interface Builder中那些烦人的警告,但我不明白它在抱怨什么(所有Interface Builder,没有代码):

来自Xcode的Sceenshot  -  Interface Builder

我指定了一个固定的固定高度和固定的距离到右边和顶部.

然而警告告诉我

Needs Constraints for: Y position, height
Needs Constraints for: X position, width
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下这些限制是不够的?

编辑
此外,当使用"自动"添加约束命令时,它什么都不做,错误仍然存​​在.

iphone constraints ipad ios autolayout

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