我的故事板中有两个视图控制器,我需要从视图1推送到视图2.
我需要在没有直接从我的故事板中的按钮连接segue的情况下执行此操作,我需要以编程方式执行此操作.
我怎么能够?
谢谢.
我有一个NSURL,一个文件路径,我想在它的末尾添加一个NSString(文件名)我该怎么做?但在此之后我不希望整个事情成为一个NSURL.
谢谢.
为iOS游戏播放背景音乐的最佳方式是什么?我该怎么做?
将该音乐文件用于播放的最佳格式是什么?
这首歌是否会在整个游戏中愉快地播放,改变观看时不会中断?
我怎么能循环这个音乐?
我一直在按照这些说明来帮助将iCloud支持与CoreData集成,并且我遇到了一些错误.
我在我的AppDelegate中有这个:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
//NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Little_Wedding_Book_Universal.sqlite"];
NSString *storePath = [[NSString stringWithFormat:@"%@", [self applicationDocumentsDirectory]] stringByAppendingPathComponent:@"appname.sqlite"];
NSURL *storeURL = [NSURL fileURLWithPath:storePath];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
NSPersistentStoreCoordinator* psc = persistentStoreCoordinator;
if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5.0"))
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSFileManager *fileManager = [NSFileManager defaultManager];
// Migrate datamodel
NSDictionary *options = nil;
// this needs to match the entitlements and provisioning profile
NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:@"J9VXW4WCE8.com.company.appname"];
NSString* coreDataCloudContent …Run Code Online (Sandbox Code Playgroud) 我想以模态方式添加一个透明背景的视图控制器,因此可以看到下面的父视图控制器.(这适用于iPhone,不适用于iPad.)
我试过这个:
TextFieldViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"TextFieldVC"];
vc.modalPresentationStyle = UIModalPresentationCurrentContext;
vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController presentViewController:vc animated:YES completion:^{}];
Run Code Online (Sandbox Code Playgroud)
没有运气,给视图控制器一个清晰的颜色背景.如果改变了什么,我的视图控制器就在故事板中.
我有这个代码:
-(void)createAndPlaySoundID: (NSString*)name
{
NSString *path = [NSString stringWithFormat: @"%@/%@", [[NSBundle mainBundle] resourcePath], name];
NSURL* filePath = [NSURL fileURLWithPath: path isDirectory: NO];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼:
[self createAndPlaySoundID: @"mySound.caf"];
Run Code Online (Sandbox Code Playgroud)
这很好用,但我无法控制音量.我只是希望用户使用iPad上的标准物理音量按钮来控制音量.
如果我把这个音量降低到1,它会播放,很好,但是如果我将设备音量调到最大它的相同音量.
任何帮助将不胜感激,处理这个,谢谢.
我正在使用NSNumberFormatter从字符串中获取货币值,它运行良好.
我使用此代码执行此操作:
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
[nf setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString *price = [nf stringFromNumber:[NSNumber numberWithFloat:[textField.text floatValue]]];
Run Code Online (Sandbox Code Playgroud)
但是,它总是在字符串的开头给我一个货币符号.而不是手动形成我给定的字符串,我不能以某种方式让格式化程序不给字符串任何货币符号?
在iOS 8上运行,我需要在旋转我的应用程序时更改UI.
目前我正在使用此代码:
-(BOOL)shouldAutorotate
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation != UIInterfaceOrientationUnknown) [self resetTabBar];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
我这样做删除了当前的UI并添加了一个适合方向的新UI.但是,我的问题是,每次进行一次旋转时,此方法被调用大约4次.
在iOS 8中对方向更改进行更改的正确方法是什么?
我正在玩一个新项目,一个使用Core Data的拆分视图iPad应用程序,我很想知道,因为它非常清楚如何添加和删除项目.如果我要改变它来保存文本,那么该文本将显示在a中UITextView,如何编辑或覆盖CoreData中的对象?
因此,用户UITextView在他们离开时键入他们的音符,然后编辑并保存他们当前选择的音符(表格视图中的对象).
感谢任何帮助.
我觉得我已经触及了阻止这个的每一个可能原因,但是我的故事板中有一个UIScrollView连接了一个插座,在viewDidLoad中我设置了contentSize以便我可以滚动(比框架大小更大)!
但是,无论我改变什么,我都无法滚动!我的滚动视图中有几个文本字段并且启用了弹跳,因此我可以看到在使用我的子视图测试其上下移动时,但无论我将contentSize设置为什么,我都无法滚动.
我可能遗失的任何东西/应该检查?这是UIScrollView在故事板中使用的已知问题吗?
甚至更奇怪的是,我可以做这样的事情:
[scrollView setBackgroundColor:[UIColor blueColor]];我有一个蓝色滚动视图!但设置内容大小失败.
我唯一的代码(否则scrollview只是放入storyboard视图控制器):
-(void)viewDidAppear:(BOOL)animated
{
[scrollView setContentSize:CGSizeMake(320, 640)];
}
Run Code Online (Sandbox Code Playgroud)
记录的帧,按预期出现:
width: 320.00
height: 504.00
Run Code Online (Sandbox Code Playgroud)
原来在我的故事板中删除滚动视图的任何子视图让它滚动得很好.如果我通过故事板添加任何子视图,即使是空白的全新UIButton,它也不会应用contentSize/allow滚动.
objective-c ×10
iphone ×6
ipad ×5
audio ×2
core-data ×2
append ×1
currency ×1
icloud ×1
ios ×1
ios8 ×1
loops ×1
macos ×1
nsstring ×1
nsurl ×1
orientation ×1
segue ×1
storyboard ×1
transparency ×1
uiscrollview ×1
uistoryboard ×1
uitextview ×1
volume ×1