我试图在视图加载后将地图缩放到用户的当前位置,但是我收到错误"***由于未捕获的异常终止应用程序'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) 我正在尝试睡一个方法(见下文),而不是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) 我想取一个 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>什么来在第一个之后添加一行?
更好的是,是否有一个模式可以搜索 < + > 之间的所有字符串并添加新行?长字符串中的字符串数量会增加和减少,因此在 < + > 之间的所有字符串上添加行的模式需要完全通用并且能够运行到文件末尾。