这是我的代码.我必须为localNotification添加任何内容.有什么建议.提前致谢.我阅读了很多本地通知教程.我不知道错过了什么.
var localNotifications : UILocalNotification!
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
localNotifications = UILocalNotification()
localNotifications.fireDate = NSDate(timeIntervalSinceNow: 20)
localNotifications.timeZone = NSTimeZone.defaultTimeZone()
localNotifications.alertBody = "Check it out!"
localNotifications.soundName = UILocalNotificationDefaultSoundName
localNotifications.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
UIApplication.sharedApplication().scheduleLocalNotification(localNotifications)
Run Code Online (Sandbox Code Playgroud)
}
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
println("Alvin Notification recieved")
if application.applicationState == UIApplicationState.Active
{
// show alertView
Utilities.sharedInstance.alertThis("Hello", message: "Hey")
}
else if application.applicationState == UIApplicationState.Background
{
UIApplication.sharedApplication().presentLocalNotificationNow(localNotifications)
}
else if application.applicationState == UIApplicationState.Inactive
{
UIApplication.sharedApplication().presentLocalNotificationNow(localNotifications)
}
application.applicationIconBadgeNumber = 0 …Run Code Online (Sandbox Code Playgroud) 我收到以下错误
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: objectid)'
Run Code Online (Sandbox Code Playgroud)
它是字典还是核心数据?我无法弄清楚崩溃发生在哪里.任何想法?
2015-03-18 12:47:23.239 OneChannelApp[3039:6403] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 2 hit(s) sent
2015-03-18 12:47:27.804 OneChannelApp[3039:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: objectid)'
*** First throw call stack:
(0x30668f83 0x3ae19ccf 0x305a48f3 0xbf357 0x32ea06df 0x3301643f 0x32f33d63 0x32f33b6d 0x32f33b05 0x32e85d59 0x32b0362b 0x32afee3b 0x32afeccd 0x32afe6df 0x32afe4ef 0x32af821d 0x30634255 0x30631bf9 0x30631f3b 0x3059cebf 0x3059cca3 0x354a2663 0x32ee914d 0x20555d …Run Code Online (Sandbox Code Playgroud) 我可以从网站上下载一个mp3,这样我以后可以在我的应用程序中使用它,而不会阻止我应用程序执行的其余部分吗?
我一直在寻找的是同步方式.
我想将mp3缓存在一个数组中.我最多只能获得5或6个短片.
有人可以帮忙吗?
我有日期和时间,我想要的是特定日期和时间的毫秒数
例如:日期21-04-2015
和日期(2015年4月21日)的时间是14:23
然后以毫秒为单位输出是1429606437692
我想要的没有毫秒从1970年到今天的日期最多14:23时
如何得到这个日期时间在毫秒iOS中?
请提前帮助和感谢.
我正在使用一个类我使用单例模式.我有静态方法.现在我想在静态方法中调用一个非静态方法.但是我无法调用它.请告诉我解决方案是什么.
#import "ThemeManager.h"
@implementation ThemeManager
+(ThemeManager *)sharedInstance
{
NSLog(@"shared instance called");
static ThemeManager *sharedInstance = nil;
if (sharedInstance == nil)
{
sharedInstance = [[ThemeManager alloc] init];
}
[self getPref];//i get error at this line
return sharedInstance;
}
-(void)getPref
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *themeName = [defaults objectForKey:@"theme"] ?: @"default";
NSLog(@"theme name is %@",themeName);
NSString *path = [[NSBundle mainBundle] pathForResource:themeName ofType:@"plist"];
self.theme = [NSDictionary dictionaryWithContentsOfFile:path];
}
@end
Run Code Online (Sandbox Code Playgroud) 我是iOS开发的新手,因此在Xcode中设置故事板上对象的约束对我来说很困难.
如下图所示,我在素描中创建的按钮有3个边框,因此它们都是图像,每个图像都在图像视图中:
我尝试通过将所有三个图像固定在左侧,右侧和下方来添加约束,但我得到了错误,并且它在模拟器上根本没有出现.所有图像都处于宽高比填充模式,当我将图像放入故事板时,我的视图大小与iPhone 4相同.这是一个没有任何约束的iPhone 6模拟器中的样子:
我需要哪些限制,以便它适用于所有iPhone和iPad尺寸,看起来像是在故事板中?横向模式不会成为此应用程序的一部分,因此不需要考虑.
我4年前开始进行iOS开发,当时只有两种屏幕尺寸需要担心.3.5英寸(非视网膜)iPhone和9.7英寸iPad.我选择iOS开发的原因之一是因为当时的Android操作系统开发不同,只有两种屏幕尺寸需要设计才能确保所有应用在所有设备上看起来都很好.
我是那种喜欢在发布我的申请之前确保一切都很完美的人.所以,我相信如果你只是在模拟器上测试你的应用程序(其中只有4个选项,两个版本的iPad用于iPad,2个用于iPhone),那么你的应用程序还没有准备好用于大时间,因为代码在实际设备上运行的方式不同.所以,四年前,我买了一台iPad并开始测试我的应用程序.
然而,这就是问题(和问题)真正进入的地方.现在有两个或三个不同尺寸的iPhone和5个不同尺寸的iPad.我不能很好地购买其中一个(我也不想)所以你们推荐什么是在所有这些不同屏幕尺寸的设备上测试我的应用程序的最佳方式?
我想开发一个应用程序,其中项目应显示为UICollectionView.当用户点击并按住项目时,所有项目应该像Apple主屏幕一样开始摇动,当我们要删除应用程序时,图标开始摇动.所以请告诉我如何实现此功能.有没有图书馆可以使用?
我有一个可在所有手机和平板电脑上运行的Swift iOS应用程序.我想为所有设备使用相同的代码库和IPA文件.在手机上应用程序应该是肖像.在平板电脑上应用应该是风景.
如果你的方向正确,我可以让它不允许旋转,但如果你在设备方向错误时启动应用程序,它将以错误的方向从应用程序开始,并强制你将手机实际旋转到解决它,即使这样屏幕搞砸了.
在常规:部署信息:设备方向:我已选中纵向和横向
请注意,这与已经提出的其他问题相似,但我找不到我的特殊情况.
我在所有视图控制器中使用此代码,以防止旋转,如果您已经在正确的方向:
override func shouldAutorotate() -> Bool
{
let orientation:UIDeviceOrientation = UIDevice.currentDevice().orientation
print(orientation)
if(UIDevice.currentDevice().userInterfaceIdiom == .Phone)
{
if(orientation.isLandscape)
{
return true
}
}
else
{
if(orientation.isPortrait)
{
return true
}
}
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask
{
if(UIDevice.currentDevice().userInterfaceIdiom == .Phone)
{
return UIInterfaceOrientationMask.Portrait
}
else
{
return UIInterfaceOrientationMask.Landscape
}
}
Run Code Online (Sandbox Code Playgroud) ios ×10
ipad ×10
iphone ×9
objective-c ×5
swift ×3
xcode ×3
cocoa-touch ×1
crash ×1
datetime ×1
oop ×1