小编Muk*_*esh的帖子

UITableView自我调整单元格滚动问题,细胞高度差异很大

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{

    let json = JSON(data: activityTableView.onlineFeedsData)[indexPath.row] // new
    if(json["topic"]["reply_count"].int > 0){
        if let cell: FeedQuestionAnswerTableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier_reply) as? FeedQuestionAnswerTableViewCell{

            cell.selectionStyle = .None
            cell.tag = indexPath.row
            cell.relatedTableView = self.activityTableView
            cell.configureFeedWithReplyCell(cell, indexPath: indexPath, rect: view.frame,key: "activityTableView")
            // Make sure the constraints have been added to this cell, since it may have just been created from scratch
            cell.layer.shouldRasterize = true
            cell.layer.rasterizationScale = UIScreen.mainScreen().scale

            return cell
        }
    }else{
        if let cell: FeedQuestionTableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as? FeedQuestionTableViewCell{

            cell.selectionStyle …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift ios8 uitableviewautomaticdimension

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

iOS从openCV cv :: Point获取CGPoint

在此输入图像描述

在上面的图像中,我们可以看到一些在图像上绘制的点openCV algorithm.

我想UIView在这些点上画一点,以便用户可以裁剪它.

我没有得到如何访问这些点,以便我可以添加uiview点.

我尝试阅读cv::Point,但值与坐标的高度和宽度不同(更多).

static cv::Mat drawSquares( cv::Mat& image, const std::vector<std::vector<cv::Point> >& squares )
{

    int max_X=0,max_Y=0;
    int min_X=999,min_Y=999;
    for( size_t i = 0; i < squares.size(); i++ )
    {
        const cv::Point* p = &squares[i][0];
        int n = (int)squares[i].size();

        NSLog(@"Squares%d %d %d",n,p->x,p->y);

        polylines(image, &p, &n, 1, true, cv::Scalar(0,255,0), 3, cv::LINE_AA);

    }


    return image;
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,drawsquare方法绘制正方形.我NSLog有点x,y坐标,但这些值与设备坐标系不相符.

有人可以帮助我如何实现它或替代我的要求.

谢谢

c++ opencv objective-c cgpoint ios

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

NSURLSessionUploadTask无法上传文件

下面是上传图像文件的片段.我只想使用NSURLSessionUploadTask,因为它提供了我想在我的应用中使用的后台上传功能.

另外我想POST参数和文件上传.

我也不擅长服务器端代码.任何人都可以指导我做错了什么.

上传代码

NSString* filePath = [[NSBundle mainBundle]
                      pathForResource:@"sample" ofType:@"jpg"];
uint64_t bytesTotalForThisFile = [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:NULL] fileSize];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:uploadPath];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"%llu", bytesTotalForThisFile] forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];

[request setTimeoutInterval:30];

NSString* filePath = [[NSBundle mainBundle]
                      pathForResource:@"sample" ofType:@"jpg"];


NSURLSessionUploadTask *taskUpload= [self.uploadSession uploadTaskWithRequest:request fromFile:[[NSURL alloc] initFileURLWithPath:filePath]];
Run Code Online (Sandbox Code Playgroud)

PHP代码

<?php

$objFile = & $_FILES["file"];
$strPath = basename( $objFile["name"] );

if( move_uploaded_file( $objFile["tmp_name"], $strPath ) ) {
    print "The file " .  $strPath . " has been uploaded.";
} …
Run Code Online (Sandbox Code Playgroud)

php file-upload nsurlconnection ios nsurlsession

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

使用波动画动画CAShapeLayer

下面我有附加图像,我想实现下面的动画.我尝试过水波动画,但不知道如何像上面那样控制动画.

我必须CAShapeLayer在其中实现此动画.

在此输入图像描述

初始代码

UIBezierPath *leftPath = [UIBezierPath bezierPath];
// Set the starting point of the shape.
[leftPath moveToPoint:CGPointMake(0,self.bounds.size.height/2)];
// Draw the lines.


[leftPath addLineToPoint:CGPointMake(0,self.bounds.size.height/2)];
[leftPath addLineToPoint:CGPointMake(self.bounds.size.width,self.bounds.size.height/2)];


leftLayer.path = leftPath.CGPath;
leftLayer.strokeColor = [[UIColor whiteColor] CGColor];
leftLayer.fillColor = nil;
leftLayer.borderWidth = 3.0f;
leftLayer.lineCap = kCALineCapRound;
leftLayer.lineJoin = kCALineJoinRound;

leftLayer.borderColor=[UIColor blackColor].CGColor;
[self.layer addSublayer:leftLayer];
Run Code Online (Sandbox Code Playgroud)

动画代码

-(void)animateCureve{

CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
pathAnimation.duration = 3.5;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = (id)leftLayer.path;
pathAnimation.toValue = (id)[self wavePath].CGPath;
pathAnimation.removedOnCompletion=NO;
[leftLayer addAnimation:pathAnimation forKey:@"path"];
}
Run Code Online (Sandbox Code Playgroud)

曲线路径

- …
Run Code Online (Sandbox Code Playgroud)

animation cashapelayer ios uibezierpath

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

iOS企业分发应用程序二维码下载问题

我们正在尝试创建此URL的QR代码:

itms-services://?action=download-manifest&url=itms-services://?action=download-manifest&url=https://url/app.plist

因此,如果用户扫描QR码,他们应该弹出一个安装应用程序的弹出窗口.

我们创建了QR码,所以当我们扫描它时会带你去Safari但安装不起作用.

此外,当我以编程方式从应用程序中点击此URL时,它可以正常工作.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"itms-services://?action=download-manifest&url=itms-services://?action=download-manifest&url=https://url/app.plist"]]
Run Code Online (Sandbox Code Playgroud)

但是当我在浏览器中手动添加它时,它不起作用.

有人可以指导我吗?难道我做错了什么?

ota ios enterprise-distribution ios-enterprise

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

Skype URI无法在iOS 9中运行

我已经实现了一个模块,用于打开各种模块聊天,通话,视频通话的Skype应用程序.它一直工作到iOS 8.

下面是链接以进行集成

https://msdn.microsoft.com/en-us/library/dn745885.aspx

但它现在停止在iOS 9中工作了.

即使安装了Skype,以下代码也只是打开App-store搜索Skype

BOOL installed = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"skype:"]];
    if(installed)
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"skype:%@?chat",dataSource[indexPath.section]]]];
    }
    else
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/in/app/skype-for-iphone/id304878510?mt=8"]];
    }
Run Code Online (Sandbox Code Playgroud)

任何替代方案?请指导.谢谢

uri skype ios skype-uri.js ios9

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

AVFoundation相机捕获缩放照片问题

下面我已经粘贴了缩放模块的代码.缩放也有点眩晕,捕获的照片的结果图像不是根据缩放,即结果图像稍微放大.可以有人指导我.谢谢

func pinchToZoom(sender:UIPinchGestureRecognizer){

    if(sender.state == .Began){
        scale = sender.scale
    }

    if(sender.state == .Began || sender.state == .Changed){

        //NEW
        var effectiveScale = scale * sender.scale
        if(effectiveScale < 1.0){
            effectiveScale = 1.0
        }
        let maxScale = self.imageOutput.connectionWithMediaType(AVMediaTypeVideo).videoMaxScaleAndCropFactor

        if(effectiveScale > maxScale){
            effectiveScale = maxScale
        }

        //Transform
        CATransaction.begin()
        CATransaction.setAnimationDuration(0.25)
        let transform = CGAffineTransformMakeScale(effectiveScale, effectiveScale)
        cameraView.transform = transform
        CATransaction.commit()

        scale = sender.scale // Store the previous scale factor for the next pinch gesture call

        do {
            try device.lockForConfiguration()
            device.videoZoomFactor = effectiveScale
            device.unlockForConfiguration()
        } catch { …
Run Code Online (Sandbox Code Playgroud)

camera avfoundation ios uipinchgesturerecognizer ios9

6
推荐指数
0
解决办法
176
查看次数

ios UITableViewCell以编程方式在drawRect vs layoutSubviews中创建

我一直试图UITableViewCell通过Autolayout 创建复杂但是它在滚动时给出了巨大的性能滞后,所以我决定采用基于帧的方式,即以编程方式.

单元格布局的复杂性就像Facebook卡片,其中每个单元格与动态文本和图像不同.

我试图渲染单元格,layoutSubviews但滚动仍然很差,但比Autolayout更好.

我也尝试渲染单元格drawRect,这提供了最佳性能但滚动时我无法更新帧,因为它只被调用一次.

有人可以指导我最好的情况,我可以用最好的滚动性能.我被卡住了.

uitableview drawrect ios layoutsubviews swift

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

检测ASTextNode AsyncDisplayKit中的链接或URL

我一直在尝试使用AsyncDisplayKit框架,我需要检测文本中的url.

我用过ASTextNode但找不到任何api来检测链接.

我读到有linkAttributeNames用于网址检测的属性,但无法找到任何示例如何做到这一点.

有人可以帮助我如何使用上述课程吗?

谢谢

uitextview ios asyncdisplaykit

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