小编Mat*_*uch的帖子

CGAffineTransformIdentity在多次转换后没有重置UIImageView?

我在顶部创建了一个带有分段控件的简单应用程序.当我单击控件的两个部分之一时,UIImageView开始旋转.我有一个重置按钮,将其变换设置为CGAffineTransformIdentity.

通过来回切换段来第二次调用执行视图旋转动画的方法时,会发生此问题.点击重置只会删除最新的动画.我必须第二次切换片段以完全重置动画停止.

当我选择旋转UIImageView的段时调用以下代码,当我在段之间单击时显然第二次调用.

// Begin the animation block and set its name
[UIView beginAnimations:@"Rotate Animation" context:nil];

// Set the duration of the animation in seconds (floating point value)
[UIView setAnimationDuration:0.5];

// Set the number of times the animation will repeat (NSIntegerMax setting would repeat indefinately) (floating point value)
[UIView setAnimationRepeatCount:NSIntegerMax];

// Set the animation to auto-reverse (complete the animation in one direction and then do it backwards)
[UIView setAnimationRepeatAutoreverses:YES];

// Animation curve dictates the speed over time of an animation …
Run Code Online (Sandbox Code Playgroud)

core-graphics objective-c cgaffinetransform ios

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

Swift与ARC之前的Objective-C不兼容吗?

我开始将Swift文件添加到一个非常大的,不使用ARC的Objective-C项目中.

当我编译项目时,我会收到ProjectName-Swift.h桥头中发出的每个属性的警告:

  • 未指定"assign","retain"或"copy"属性 - 假定为"assign"
  • 默认属性"assign"不适合非GC对象

似乎Swift正在发布基于ARC的Objective-C代码.

这是Swift特定版本中的限制/错误,还是Swift只能用于ARC代码?

objective-c automatic-ref-counting swift

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

为什么PNG图像有时会变得模糊,具体取决于它在视图中的位置

我注意到,当使用IB将PNG图像放入视图和/或将这些图像设置为视图周围的不同位置时,图像有时会出现轻微模糊.

在大多数情况下,我可以通过在图像位置添加.5像素来弥补模糊.

[lbLiteButton.layer setPosition:CGPointMake(140.5,159.5)];
Run Code Online (Sandbox Code Playgroud)

有时我必须像上面那样调整x和y.有时我只需要调整x y.

我记得在某处读到这与图像的大小以及核心动画的工作原理以及与半像素的关系有关......但我无法在任何地方找到这篇文章!?

".5像素"解决方案的问题在于每个PNG图像的大小不同,因此您无法重复使用自定义动画,因为您必须为每个不同的图像自定义它.

  1. 有没有办法确保无论我在哪里放置或动画我的图像,我都不会得到任何模糊的位置?
  2. 有没有人有这方面的任何信息?

谢谢!

iphone png core-animation blur

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

在iphone中使用coregraphics绘制文本

如何在iphone中使用coregraphics在imageview上绘制文本

iphone text core-graphics

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

如何在进行更改后使UIAlertView调用`alertViewShouldEnableFirstOtherButton:`

我有一个带UITextField的UIAlertView.我连接了UIAlertView委托,并alertViewShouldEnableFirstOtherButton:根据UITextField中的文本返回YES或NO .

我需要以编程方式更改textField的文本.这按预期工作.

不幸的是我不知道如何让UIAlertView调用alertViewShouldEnableFirstOtherButton:委托方法,因此在我更改textField的文本后启用或禁用其他按钮.

我认为UIAlertView注册为UITextField的目标,所以我尝试UIControlEventValueChanged从textField 发送一个.没工作.


从堆栈跟踪中我发现从私有UIAlertView方法调用委托方法_alertSheetTextFieldDidChange:.

因此,如果我[self.currentAlert performSelector:@selector(_alertSheetTextFieldDidChange:) withObject:textField];在更改文本后执行操作,则会调用委托方法并更改按钮的启用状态.但是,由于这是一种私有方法,应用程序可能会被拒绝.我不想冒这个风险.


是否有一种干净的方式来进行警报视图调用alertViewShouldEnableFirstOtherButton:

cocoa-touch uialertview ios

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

这些if(0)条件有什么意义?

我发现它是开源的,我正在查看一些CFArray代码,我发现了一些奇怪的代码.这些"空" if (0)条件有什么意义?是否有一些疯狂的好处,或者这只是遗留下来的东西?此代码位于GitHub的CFArray.c的第957行.

if (0) {

} 
else if (NULL == array->_store) {
    if (0) {

    } 
    else if (0 <= futureCnt) {
           // blah blah
    }
}
Run Code Online (Sandbox Code Playgroud)

if-statement objective-c core-foundation

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

如何将UIImage序列化为JSON?

我在用

imageData = UIImagePNGRepresentation(imgvw.image);

并在发布时

[dic setObject:imagedata forKey:@"image"]; 
Run Code Online (Sandbox Code Playgroud)

NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&theError];

现在应用程序由于未捕获的异常而崩溃终止应用程序' NSInvalidArgumentException',原因:'JSON写入中的无效类型(NSConcreteMutableData)

ios nsjsonserialization

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

IOS 7中选项卡栏图标的状态

我正在学习构建我的第一个iPhone应用程序,并想知道是否有人会指出我正确的方向.

我基本上为我的标签栏(IOS 7)添加了自定义图标.现在我想为每个添加自定义选择状态图标.我该怎么做?

谢谢

贝壳

uitabbaritem uitabbar ios7

7
推荐指数
2
解决办法
8697
查看次数

AFNetworking 2.0 HTTP POST进度


我怎样才能获得AFHTTPRequest的进展?我试过在网上搜索.
我在用:

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *params = @{@"gameId" : datas[0], @"p1": datas[1], @"p2":datas[2], @"turn":datas[3] };
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:@"http://localhost/thepath/isprivate/thefile.php"
       parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    }];
Run Code Online (Sandbox Code Playgroud)

是否有我可以用来访问AFNetworking 2.0 HTTP POST进度的属性或方法?

objective-c ios afnetworking-2

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

在Swift中将输入字段字符串转换为Int

所以我非常擅长制作APP广告Swift,我试图在文本字段中做一些非常简单的输入,取值,然后将它们用作Int进行一些计算.

但是'var distance'的某些方法是行不通的

        var handicapTal:Int
        var MagicNumber:Int
        var handicap = inputHCP.text.toInt()
        var distance = inputDistance.text.toInt()

        if (handicap >= 0 && handicap <= 20)
        {
            handicapTal = 30
        }
        else if(handicap > 20 && handicap <= 40){
            handicapTal = 10
        }

        MagicNumber = distance - handicapTal
Run Code Online (Sandbox Code Playgroud)

它是导致错误的最后一行代码.它说致命错误:无法解开Optional.None

ios swift

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