小编buz*_*kip的帖子

MKMapView缩放到viewDidLoad上的用户位置?

我试图在视图加载后将地图缩放到用户的当前位置,但是我收到错误"***由于未捕获的异常终止应用程序'NSInvalidArgumentException',原因:'无效区域' "当视图加载时.请有人帮忙吗?

干杯!

- (void)viewDidLoad
{
    [super viewDidLoad];

    MKCoordinateRegion mapRegion;   
    mapRegion.center.latitude = map.userLocation.coordinate.latitude;
    mapRegion.center.longitude = map.userLocation.coordinate.longitude;
    mapRegion.span.latitudeDelta = 0.2;
    mapRegion.span.longitudeDelta = 0.2;
    [map setRegion:mapRegion animated: YES];   
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c

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

叫睡(5); 并更新文本字段不起作用

我正在尝试睡一个方法(见下文),而不是textLabel从值的变化myTextLabelString,等待5秒,改为"睡5工作",等待5秒,最后改为"睡5工作第二轮" ....它只是从值开始myTextLabelString,等待10秒,然后变为"睡眠5第二次工作".

- (void)textLabelChanger:(id)sender {

    NSString *myTextLabelString = [NSString stringWithFormat:@"%d", gameCountDown];    

    textLabel.text=myTextLabelString;
    sleep(5);
    textLabel.text=@"sleep 5 worked";
    sleep(5);
    textLabel.text=@"sleep 5 worked second time round";
    return;
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch sleep objective-c ios

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

正则表达式 - 在找到的字符串后添加新行?(分割很长的字符串)

我想取一个 LONG 单行文本字符串,并将其拆分为多行。

例如,拿这个:

<random-text-doesn't-matter-what-this-is><random-text-doesn't-matter-what-this-is><random-text-doesn't-matter-what-this-is><random-text-doesn't-matter-what-this-is>
Run Code Online (Sandbox Code Playgroud)

并替换为:

<random-text-doesn't-matter-what-this-is>
<random-text-doesn't-matter-what-this-is>
<random-text-doesn't-matter-what-this-is>
<random-text-doesn't-matter-what-this-is>
Run Code Online (Sandbox Code Playgroud)

我可以使用以下方法获取 < + > 之间的第一个字符串:

^[^>]*>
Run Code Online (Sandbox Code Playgroud)

但是我会向^[^>]*>添加<random-text-doesn't-matter-what-this-is>什么来在第一个之后添加一行?

更好的是,是否有一个模式可以搜索 < + > 之间的所有字符串并添加新行?长字符串中的字符串数量会增加和减少,因此在 < + > 之间的所有字符串上添加行的模式需要完全通用并且能够运行到文件末尾。

regex notepad++

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

标签 统计

cocoa-touch ×2

objective-c ×2

ios ×1

iphone ×1

notepad++ ×1

regex ×1

sleep ×1