我目前正在使用Swift开发一个应用程序,我使用UIPickerView,请参阅下面的图像.目前UIPickerView在用户滚动到最后一个数据时停止,但我希望它永远不会停止.我希望可以从第一个数据开始,只需在底部继续滚动即可.或者在顶部向上滚动.我希望它像Apple的Countdown,你可以随时向上或向下拖动.
我希望如何:

目前的情况如何:

在我的应用程序中,如果之前和/或之后没有页面,我不希望它可以拖动.
见下图.
如果当前页面之前或之后没有页面,我不希望它能够移动.无论你拖多少,如果之前和/或之后没有页面,我希望它像第二张图像一样保持静止.
拖动时的情况如下:

在拖动之前和/或之后没有页面时我希望如何:

即使iPhone处于静音模式,我正在制作一个需要播放声音的应用程序,但是我现在拥有的代码(看看这篇文章的底部)如果iPhone处于静音模式,它就不会播放声音.
我使用以下代码:
Viewcontroller.h:
@interface SoundViewController : UIViewController <UICollectionViewDataSource, UIApplicationDelegate, AVAudioPlayerDelegate, ADBannerViewDelegate, UIActionSheetDelegate> {
SystemSoundID SoundID;
NSString *listPath;
}
Run Code Online (Sandbox Code Playgroud)
ViewController.m:
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (__bridge CFStringRef) [mainArray objectAtIndex:indexPath.row], CFSTR("wav"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
Run Code Online (Sandbox Code Playgroud) 我正在尝试为UICollectionView保存indexPath,但是我收到以下错误:
libc++abi.dylib: terminating with uncaught exception of type NSException
Run Code Online (Sandbox Code Playgroud)
我的代码是:保存索引路径:
[[NSUserDefaults standardUserDefaults] setObject:indexPath forKey:@"CollectionIndex"];
[[NSUserDefaults standardUserDefaults] synchronize];
Run Code Online (Sandbox Code Playgroud)
加载indexPath:
NSIndexPath *storedIndexPath = [[NSUserDefaults standardUserDefaults] objectForKey:@"CollectionIndex"];
Run Code Online (Sandbox Code Playgroud)
我已经注释掉代码以找出导致错误的代码,这是我用来保存创建SIGABRT错误的indexPath的代码.
有一个应用程序,我在其中显示用户在地址中的当前位置.问题是,如果例如邮政编码或管理区域不可用,则字符串将打印(null)该值应保留的位置 - 所有其他数据都在那里.
例:
(null)19号路
(null)孟买
马哈拉施特拉邦
我想知道的是,是否可以只有一个空格而不是(null)?
我目前的代码:
_addressLabel.text = [NSString stringWithFormat: @"%@ %@\n%@ %@\n%@",
placemark.subThoroughfare, placemark.thoroughfare,
placemark.postalCode, placemark.locality,
placemark.administrativeArea];
Run Code Online (Sandbox Code Playgroud) 我正在开发的应用程序将在用户给出特定时间后播放歌曲,例如34分钟后.我不希望有必要让应用程序打开,我希望它可以退出应用程序.我面临的问题是,当锁定手机或只是按主屏幕时,NSTimer不起作用.我在网上搜索过,但我没有找到任何适用于Swift和iOS 8的解决方案.
ios ×5
ios8 ×2
objective-c ×2
swift ×2
audio ×1
iphone ×1
nsindexpath ×1
nsstring ×1
nstimer ×1
string ×1
uipickerview ×1