我正在尝试为应用程序开发一个指南针,它在地图上有一组注释.我希望能够选择一个注释,然后让指南针将用户指向所选位置.
我已经计算了从用户位置到注释位置的degress,我有磁性标题和iPhone的真实标题.我也知道如何旋转图像.但我无法弄清楚下一步是什么.
用户位置和注释位置之间的度数计算如下:
// get user location
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
float x1 = coordinate.latitude;
float y1 = coordinate.longitude;
float x2 = [annLatitude floatValue];
float y2 = [annLongitude floatValue];
float dx = (x2 - x1);
float dy = (y2 - y1);
if (dx == 0) {
if (dy > 0) {
result = 90;
}
else …Run Code Online (Sandbox Code Playgroud) 我正在使用SDWebImage将图像加载到我的表视图中.我希望我的表视图中的图像可以调整大小并具有圆角.我找到了UIImage + Resize和UIImage + RoundedCorner来做到这一点.两个图书馆分开工作很好,但我还没有结合它们.我可以调整大小并绕过SDWebImage返回的图像的角落,但我发现这是相当重的资源,因此我希望在将图像保存到缓存之前调整图像大小.当第一次从网络加载图像时,它可能会在保存到缓存之前显示,因此我还想在第一次加载图像时调整图像大小.
我无法做到这一点,因为我无法弄清楚SDWebImage的哪种方法来操纵图像.我只需要在SDWebImage中的右侧UIImage上调用以下内容.
UIImage *image = [image thumbnailImage:50 transparentBorder:0 cornerRadius:5 interpolationQuality:kCGInterpolationHigh];
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我在SDWebImage中我应该放置这段代码,以便在保存到缓存之前操作图像,并在从Internet而不是缓存加载图像视图时将操作图像发送到图像视图?
我想将语音从一个iPhone传输到另一个iPhone.我已经使用TCP建立了两个iPhone之间的连接,我已经设法在iPhone上录制语音并使用音频队列服务播放它.我还设法在两个iPhone之间发送数据.我这样做是通过发送NSData包.
我的下一步是将音频数据发送到正在录制的其他iPhone.我相信我应该这样做AudioInputCallback.我AudioQueueBufferRef被调用inBuffer,似乎我想转换inBuffer->mAudioData为NSData,然后将NSData发送到另一个设备,然后解压缩它.
有谁知道这是否是这样做的方式以及如何将我转换inBuffer->mAudioData为NSData?其他方法也受到欢迎.
这是我的回调方法,我相信我应该"抓住"数据并将其发送到其他iPhone:
void AudioInputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, const AudioTimeStamp *inStartTime, UInt32 inNumberPacketDescriptions, const AudioStreamPacketDescription *inPacketDescs)
{
RecordState *recordState = (RecordState *)inUserData;
if(!recordState->recording)
return;
OSStatus status = AudioFileWritePackets(recordState->audioFile,
false,
inBuffer->mAudioDataByteSize,
inPacketDescs,
recordState->currentPacket,
&inNumberPacketDescriptions,
inBuffer->mAudioData);
if(status == 0)
{
recordState->currentPacket += inNumberPacketDescriptions;
}
AudioQueueEnqueueBuffer(recordState->queue, inBuffer, 0, NULL);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试匹配正则表达式中的一个组,但我不希望这个组在最终结果中.
例如:
((kl(\.)?|at)?([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)
运行上面的表达式at 12:25应该返回12:25.
有没有办法做到这一点?
我试过用:
(?:((kl(\.)?|at)? )([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)
但这没什么区别.
然后我试了一下
(?<!(?:((kl(\.)?|at)? )([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)
但那返回了一个空洞的结果.
我在C#中使用表达式.
我创建了一个使用RMSharedPreferences框架的Mac应用程序.打开应用程序时,它立即崩溃,我收到以下错误:
Dyld Error Message:
Library not loaded: @rpath/RMSharedPreferences.framework/Versions/A/RMSharedPreferences
Referenced from: /Users/USER/Desktop/MyApp.app/Contents/MacOS/MyApp
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
似乎找不到框架.我已经尝试将复制文件阶段添加到目标,该目标应该复制框架,当在Finder中浏览应用程序的内容时,它似乎被正确复制.
有谁知道什么可能导致这个错误?
编辑:将框架设置为可选确实使应用程序启动没有任何错误,但应用程序不能完全工作.任何与RMSharedPreferences相关的调用都将被忽略.

我有一个UITableView,我已经分配了部分.当使用带有indexPath.row的didSelectRowAtIndex时,我没有得到正确的值.假设我在第2部分,然后它再次将行索引设置为0,因此我得到了错误的索引.
谁能告诉我如何解决这个问题?我意识到可以通过indexPath.section获取段索引,但我无法弄清楚如何使用它.
bandDetailViewController.band = [self.programArray objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
我希望你能帮助我.提前致谢 :-)
编辑:
样本数据.表视图的我的单元格是从此plist加载的.
<array>
<dict>
<key>name</key>
<string>Alphabeat</string>
<key>description</key>
<string>Long description.</string>
<key>scene</key>
<string>Store Scene</string>
<key>date</key>
<date>2011-02-04T20:09:40Z</date>
<key>hasDate</key>
<true/>
<key>weekDay</key>
<string>Onsdag</string>
<key>youtubeVideo</key>
<string>http://www.youtube.com/watch?v=dB01PTZNpBc</string>
</dict>
<dict>
<key>name</key>
<string>Anne Linnet</string>
<key>description</key>
<string>Long description.</string>
<key>scene</key>
<string>Store Scene</string>
<key>date</key>
<date>2011-02-04T20:09:40Z</date>
<key>hasDate</key>
<true/>
<key>weekDay</key>
<string>Onsdag</string>
<key>youtubeVideo</key>
<string>http://www.youtube.com/watch?v=jWMSqS7fL9k</string>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud) 我在两个iPhone之间建立了TCP连接,我可以在两者之间发送NSData包.我想谈谈麦克风并将录音作为NSData对象并将其发送到其他iPhone.我成功地使用了音频队列服务来录制音频并播放它,但我还没有成功将录音作为NSData.我发布了一个关于在使用音频队列服务时将录音转换为NSData的问题,但它没有让我更进一步.
因此,我想听听是否有其他方法可以用来对付iPhone的麦克风,并将输入作为原始数据?
更新:
我需要在录制时连续发送包裹.例如,每次录制时我都会发送在第二天录制的数据.
我需要在显示拆分视图控制器之前呈现模态视图控制器.我需要这个,因为用户必须登录.
我看了这个论坛上暗示,模态视图控制器应该从AppDelegate中呈现,但试图这样做的时候,什么也没发生的答案.
我已经在我的界面的其余部分所在的故事板中设置了我的视图控制器,并且我已经为视图控制器提供了标识符loginViewController.我试图在AppDelegate中显示视图控制器,如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
UISplitViewController *splitViewController = (UISplitViewController *) self.window.rootViewController;
UINavigationController *navigationController = splitViewController.viewControllers.lastObject;
splitViewController.delegate = (id) navigationController.topViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
LoginViewController *lvc = (LoginViewController *) [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"];
lvc.modalPresentationStyle = UIModalPresentationFullScreen;
[splitViewController presentModalViewController:lvc animated:YES];
}
[_window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,没有任何反应.没有错误,没有模态视图控制器,没有任何东西.应用程序只显示我的拆分视图控制器.
在显示拆分视图控制器之前,有人能告诉我如何显示模态视图控制器吗?
我知道有很多关于这个问题的线索,但我没有找到解决我的问题的线程.
我正在尝试打印一个字符串但是在打印时它没有显示特殊字符(例如æ,ø,å,ö和ü).当我使用repr()这个打印字符串时,我得到的是:
u'Von D\xc3\xbc' 和 u'\xc3\x96berg'
有谁知道我怎么能把它转换成Von Dü和 Öberg?对我来说重要的是这些字符不会被忽略,例如myStr.encode("ascii", "ignore").
编辑
这是我使用的代码.我用BeautifulSoup来抓一个网站.<td>table(<table>)中cell()的内容被放入变量中name.这是包含我无法打印的特殊字符的变量.
web = urllib2.urlopen(url);
soup = BeautifulSoup(web)
tables = soup.find_all("table")
scene_tables = [2, 3, 6, 7, 10]
scene_index = 0
# Iterate over the <table>s we want to work with
for scene_table in scene_tables:
i = 0
# Iterate over < td> to find time and name
for td in tables[scene_table].find_all("td"):
if i % 2 == …Run Code Online (Sandbox Code Playgroud) 我使用iCloud存储iPad应用程序的核心数据信息.我使用Magical Record提供的辅助方法来处理与Core Data相关的所有内容.
昨天我的应用程序在访问Core Data时开始表现得很奇怪.即使数据库完全为空(应用程序的干净安装),应用程序也会完全冻结并花费大量时间加载.等了好几分钟之后会发出一个错误,说iCloud超时了.出现以下错误:
-[PFUbiquitySafeSaveFile waitForFileToUpload:](268): CoreData: Ubiquity: <PFUbiquityPeerReceipt: 0x1f85c580>(0)
permanentLocation: <PFUbiquityLocation: 0x1f85c5d0>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~mydomain~MyAppName/mobile.D2EB3F30-70E9-5405-931D-B7217274BA1C/com.mydomain.MyAppName/HExUvqv20os5L2c5u1DeTzBs3lEpOwzkgw1MsXYupPg=/receipt.0.cdt
safeLocation: <PFUbiquityLocation: 0x1f85ce30>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~mydomain~MyAppName/mobile.D2EB3F30-70E9-5405-931D-B7217274BA1C/com.mydomain.MyAppName/HExUvqv20os5L2c5u1DeTzBs3lEpOwzkgw1MsXYupPg=/mobile.D2EB3F30-70E9-5405-931D-B7217274BA1C.0.cdt
currentLocation: <PFUbiquityLocation: 0x1f85ce30>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~mydomain~MyAppName/mobile.D2EB3F30-70E9-5405-931D-B7217274BA1C/com.mydomain.MyAppName/HExUvqv20os5L2c5u1DeTzBs3lEpOwzkgw1MsXYupPg=/mobile.D2EB3F30-70E9-5405-931D-B7217274BA1C.0.cdt
kv: (null)
Safe save failed for file, error: Error Domain=NSCocoaErrorDomain Code=512 "The file upload timed out." UserInfo=0x1f85d520 {NSLocalizedDescription=The file upload timed out.}
2013-01-03 16:03:35.276 MyAppName[188:1503] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0x12059c) Error: The file upload timed out.
2013-01-03 16:03:35.277 MyAppName[188:1503] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0x12059c) Error Message: The file upload timed out.
2013-01-03 16:03:35.278 MyAppName[188:1503] +[MagicalRecord(ErrorHandling) defaultErrorHandler:](0x12059c) Error Domain: …Run Code Online (Sandbox Code Playgroud)