小编Nag*_*jun的帖子

swift UITableView设置rowHeight

我试图tableView使用以下代码将每行的高度设置为相应单元格的高度:

override func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
      var cell = tableView.cellForRowAtIndexPath(indexPath)
      return cell.frame.height
}
Run Code Online (Sandbox Code Playgroud)

初始化时出现此错误var cell:

线程1:EXC_BAD_ACCESS(代码= 2,地址= 0x306d2c)

xcode uitableview swift

56
推荐指数
5
解决办法
13万
查看次数

如何将CGPoint添加到NSMutableArray?

我想将我的CGPoint存储到NSMutable数组中,所以,我有这样的方法:

[self.points addObject:CGPointMake(x, y)];
Run Code Online (Sandbox Code Playgroud)

但我得到了错误,它说:

"addObject"的参数1的类型不兼容.

所以,我查看了API,

- (void)addObject:(id)anObject
Run Code Online (Sandbox Code Playgroud)

anObject要添加到接收者内容末尾的对象.该值不得为零.

所以,我认为" CGPointMake "可以创建一个Object,但它无法分配.怎么了?

iphone objective-c nsarray cgpoint

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

如何在特定的NSString之后从NSString中删除字符

我有一个字符串如下

NSString str1 = @"Hello your bal = 68094";
Run Code Online (Sandbox Code Playgroud)

我想在字符串中遇到"="符号后删除所有字符.

任何人都可以给我解决方案吗?

nsstring ios

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

字符串到CLLocation纬度和经度

我有两个代表纬度和经度的字符串,如:" - 56.6462520",我想分配给一个CLLocation对象来比较我当前的位置.我尝试了下面的代码,但我只得到错误:

CLLocation * LocationAtual = [[CLLocation alloc]init];
LocationAtual.coordinate.latitude = @"-56.6462520";
LocationAtual.coordinate.longitude = @"-36.6462520";
Run Code Online (Sandbox Code Playgroud)

然后将对象与我的实际位置纬度和经度进行比较.有什么建议?

string iphone objective-c cllocation

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

Settings.bundle版本号更新为$(MARKETING_VERSION)

我有一个应用,当我从

XCode>常规>版本

但是最近我已将XCode更新为11.0,似乎脚本无法按预期工作:

version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $SRCROOT/MyApp/Info.plist`
version+=" ("
version+=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $SRCROOT/MyApp/Info.plist`
version+=")"
/usr/libexec/PlistBuddy "$SRCROOT/MyApp/Settings.bundle/Root.plist" -c "set PreferenceSpecifiers:1:DefaultValue $version"
Run Code Online (Sandbox Code Playgroud)

上面的脚本假设可以自动更新版本,并且可以在“设置”>“应用”中看到。

在此处输入图片说明

但是问题是,此脚本是否需要进行任何更改才能从XCode自动更新版本号?

当前,当版本从XCode> General> Version递增时,脚本将其替换为$(MARKETING_VERSION),这是不正确的。

versioning scripting ios settings.bundle xcode11

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

如何在ios 8中获取键盘位置并在numberPad上添加DONE按钮

我使用下面的代码从视图中获取键盘位置并在其上添加DONE按钮.但是在ios 8中它无法获得键盘位置,因此不会添加DONE按钮.

UIWindow *tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];

UIView *keyboard;

for (int i = 0; i < [tempWindow.subviews count]; i++)
{
    keyboard = [tempWindow.subviews objectAtIndex:i];
    // keyboard view found; add the custom button to it

    if ([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES)
    {
        [keyboard addSubview:doneButton];
    }
}
Run Code Online (Sandbox Code Playgroud)

keyboard ios8

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

比较给定数组和两个日期范围swift的日期

嗨我有一个问题场景与日期比较与给定的日期范围,场景如下:

我有一个包含数据的数组:

var filter1Date = [String]()

filter1Date[Wed, 06 May 2015 03:44:19 GMT, Wed, 06 May 2015 03:36:27 GMT, Wed, 06 May 2015 02:56:51 GMT, Wed, 06 May 2015 01:54:25 GMT, Tue, 05 May 2015 19:17:18 GMT, Wed, 06 May 2015 02:57:59 GMT, Wed, 06 May 2015 02:07:38 GMT, Wed, 06 May 2015 01:53:14 GMT, Tue, 05 May 2015 14:30:10 GMT, Tue, 05 May 2015 14:04:34 GMT]
Run Code Online (Sandbox Code Playgroud)

现在我有两个日期这给两个日期例如:

var fromDate = "dd-MM-yyyy"
var toDate = "dd-MM-yyyy"
Run Code Online (Sandbox Code Playgroud)

现在我想比较 …

cocoa-touch compare nsdate swift xcode6

0
推荐指数
1
解决办法
963
查看次数