小编Dec*_*nna的帖子

如何阻止图像在UIImageView中拉伸?

我有一个UIImageView我设置帧大小的地方x = 0, y = 0, width = 404, height = 712.在我的项目中,我需要UIImageView动态更改图像.

我正在使用此代码更改图像:

self.imageView.image = [UIImage imageNamed:@"setting-image.png"];
Run Code Online (Sandbox Code Playgroud)

问题是,当*.png图像尺寸小于UIImageView帧尺寸时,图像会拉伸.我不希望它伸展.有没有办法做到这一点?

cocoa-touch stretching uiimageview uiimage ios

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

使用哪种Android数据存储技术?

android文档在下面有以下选项,但没有解释每种情况最适合的情况.每种方法的优缺点是什么?例如,在什么条件下SQL会优于共享首选项?

  • 共享首选项
  • 内部存储器
  • 外部存储
  • SQLite数据库
  • 网络连接

java sqlite android data-storage sharedpreferences

47
推荐指数
3
解决办法
3万
查看次数

如何进行十次以上的性能测试?

默认情况下,Xcodes性能测试运行十次,结果是十次测试的平均值.问题是每次运行时平均结果差别很大,所以我必须运行测试至少五次以获得收敛结果.这既乏味又耗时; 有没有办法配置XCode或单元测试本身运行十次以上?

在此输入图像描述

xcode performance-testing ios xctest swift

21
推荐指数
3
解决办法
1002
查看次数

如何找出触摸事件结束的视图?

我希望将UIImage拖到几个UIButtons中的一个上,并根据我拖动它的按钮重新定位它.

我遇到的问题是UITouch只记录触摸开始的视图,我想访问我的触摸结束的视图.我怎样才能做到这一点?

码:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];

    dealerBtnOrigin = [touch locationInView:self.view];

    //NSLog(@"%u %u",touch.view.tag, ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]).tag);
    //CHECK TO SEE WHICH BUTTON WAS TOUCHED
    if (touch.view == ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]))
    {
        ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]).center = location;
    }
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];


    if (touch.view == ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]))
    {
        ((UIView *)[dealerBtns objectAtIndex:[table getButtonSeat]]).center = …
Run Code Online (Sandbox Code Playgroud)

objective-c touch uitouch ios

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

如果速度太慢,如何使性能测试失败?

我希望我的测试失败,如果它运行慢于0.5秒,但平均时间只是打印在控制台中,我找不到访问它的方法.有没有办法访问这些数据?

//Measures the time it takes to parse the participant codes from the first 100 events in our test data.
func testParticipantCodeParsingPerformance()
{
    var increment = 0
    self.measureBlock
    {
        increment = 0
        while increment < 100
        {
            Parser.parseParticipantCode(self.fields[increment], hostCodes: MasterCalendarArray.getHostCodeArray()[increment])
            increment++
        }
    }
    print("Events measured: \(increment)")
}
Run Code Online (Sandbox Code Playgroud)

测试数据

[Tests.ParserTest testParticipantCodeParsingPerformance]'测量[时间,秒]平均值:0.203,相对标准偏差:19.951%,值:[0.186405,0.182292,0.179966,0.177797,0.175820,0.205763,0.315636,0.223014,0.200362,0.178165]

performance performance-testing ios swift

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

如何确定我的SIGTrap崩溃的原因?

我的团队最近推出了一个应用程序,其中有很多SIGTRAP崩溃.以前我发现这些相对简单,因为它是在一个有问题的功能中发现一个不良的力量施放或一个隐含的未包裹的可选被设置为零的问题.这次虽然我找不到那种东西.我最好的猜测是,TimeBlock由于日历错误,可能其中一个对象或其属性为零.

我们的应用程序是一个会议组织者,在FreeTime,Conflicts和Meeting方面向用户显示他们的原生iOS日历事件TimeBlocks.我可以访问几个崩溃用户的日历.

Apple SigTrap定义

如果在运行时遇到意外情况,则Swift代码将以此异常类型终止,例如:

  • 具有nil值的非可选类型
  • 强制类型转换失败

崩溃功能

    /**
    Updates the conflictHours and meetingHours according to the timeblocks
    it is used as quick light reference to the button
 */
func updateTimeHours(timeblocks : [Timeblock]) {
    for timeblock in timeblocks {
        switch timeblock {
        case is MeetingTimeblock:
            for i in timeblock.startHour...timeblock.endHour {
                self.meetingHours[i] = true
            }
            break
        case is ConflictTimeblock:
            for i in timeblock.startHour...timeblock.endHour {
                self.conflictsHours[i] = true
            }
            break
        default: break
        }
    }
    updateButtonByOffset(offset: self.scrollTimeline.contentOffset.x)
}
Run Code Online (Sandbox Code Playgroud)

召唤崩溃函数 …

crash crash-reports ios swift

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

如何从JavaDoc中删除R.java

我尝试使用eclipse生成Java文档,然后使用"在浏览器中预览附加JavaDoc"选项预览我的JavaDocumenttation.

所有自动生成的Android类如R.drawable都存在.我该如何删除它们?我应该删除它们吗?

在此输入图像描述

java eclipse android javadoc r.java-file

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

如何在Egit中将当前分支更改为master?

我想知道如何在Egit eclipse插件中执行此操作.git已多次询问此问题,但答案涉及我无法访问或知道的某种形式的命令语言.使用eclipse接口如何使测试分支成为主分支而不占用原始主分支有缺陷的代码(即没有合并)

在此输入图像描述

eclipse git version-control master egit

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

Swift - 表达式列表中的预期表达式

我是Swift的新手,但不知道这意味着什么.在下面的代码行中,我在参数[String]之后有"表达式列表中的预期表达式".同时它正在寻找"预期","分隔符.我相信这些是相关的.

AppDelegate.submitLacunaRequest(module: "empire", method: "login", parameters[String]:["myuserid", "mypassword", "mykey"]) {

            responseObject, error in

            // some network error or programming error

            if error != nil {
                println("error = \(error)")
                println("responseObject = \(responseObject)")
                return
            }

            // network request ok, now see if login was successful

            if let responseDictionary = responseObject as? NSDictionary {
                if let errorDictionary = responseDictionary["error"] as? NSDictionary {
                    println("error logging in (bad userid/password?): \(errorDictionary)")
                } else if let resultDictionary = responseDictionary["result"] as? NSDictionary {
                    println("successfully logged in, refer to resultDictionary …
Run Code Online (Sandbox Code Playgroud)

regex ios swift

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

更改xml drawable图标的颜色

有没有办法将颜色设置为可绘制的图标?那么图标的颜色会被我的自定义颜色覆盖?

 <item android:drawable="@drawable/icon1"
  //set color to my icon here
    android:state_pressed="true" />
<item android:drawable="@drawable/icon2"
  //set color to my icon here
  />
Run Code Online (Sandbox Code Playgroud)

android android-xml

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