我有一个UITableView,显示当月的费用(见截图):
我的问题是空部分的标题.有没有办法隐藏它们?数据从coredata加载.
这是生成标题标题的代码:
TitleForHeader
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
return nil;
} else {
NSDate *today = [NSDate date ];
int todayInt = [dataHandler getDayNumber:today].intValue;
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:(-(todayInt-section-1)*60*60*24)];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] objectAtIndex:0]]];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
return formattedDateString;}
}
Run Code Online (Sandbox Code Playgroud)
ViewForHeader
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
return nil;
} else {
UIView *headerView = …Run Code Online (Sandbox Code Playgroud) 我试图随机选择一个枚举值,这是我目前的尝试:
enum GeometryClassification {
case Circle
case Square
case Triangle
case GeometryClassificationMax
}
Run Code Online (Sandbox Code Playgroud)
和随机选择:
let shapeGeometry = ( arc4random() % GeometryClassification.GeometryClassificationMax ) as GeometryClassification
Run Code Online (Sandbox Code Playgroud)
然而,这无可救药地失败了.
我得到的错误如下:
'GeometryClassification' is not convertible to 'UInt32'
Run Code Online (Sandbox Code Playgroud)
关于如何解决这个问题的任何想法?
我正在将AWS Mobile HUD与AWS SNS一起使用并遇到问题.
什么有效/已经完成了
以下代码应使用AWS SNS注册应用程序(设备):
pushManager = AWSPushManager(forKey: ServiceKey)
pushManager?.delegate = self
pushManager?.registerForPushNotifications()
Run Code Online (Sandbox Code Playgroud)
并且 - 足够大,func pushManagerDidRegister(_ pushManager: AWSPushManager)被称为成功.我func pushManagerDidRegister(_ pushManager: AWSPushManager)看起来像
func pushManagerDidRegister(_ pushManager: AWSPushManager) {
print("Successfully enabled Push Notifications on platform: \(pushManager.platformARN)")
// Subscribe the first topic among the configured topics (all-device topic)
if let defaultSubscribeTopic = pushManager.topicARNs?.first {
let topic = pushManager.topic(forTopicARN: defaultSubscribeTopic)
topic.subscribe()
}
}
Run Code Online (Sandbox Code Playgroud)
日志输出:
Successfully enabled Push Notifications on platform: …Run Code Online (Sandbox Code Playgroud) 控制器逻辑:
def updateObject() {
Object o = Object.get(params.id as Long)
o.otherObjects.clear()
objectDataService.saveObject(o.id)
OtherObject newObject = new OtherObject;
o.addToOtherObjects(newObject)
objectDataService.saveObject(o.id)
}
Run Code Online (Sandbox Code Playgroud)
ServiceLogic
def saveObject(long profileId) {
o.save(flush:true)
}
Run Code Online (Sandbox Code Playgroud)
怎么了
在90%的情况下,这将起作用.
问题
ERROR errors.GrailsExceptionResolver - StaleObjectStateException occurred when processing request: [GET] /controller/updateObject - parameters:
stuff[]: data
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.path.Object#1].
Stacktrace follows:
Message: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.path.Object#1]
Run Code Online (Sandbox Code Playgroud)
我已阅读相关问题并找到merge您在上面看到的电话.它解决了大约50%的案例,但并非全部.
我有以下问题.我们创建了一个游戏中心应用程序,它提供了一个框架来创建临时wifi游戏并管理这些游戏的高分/遭遇.
高分的数据库访问是通过提供者完成的:
<provider
android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider"
android:authorities="com.identifier.gamecenterapp.contentprovider" >
</provider>
Run Code Online (Sandbox Code Playgroud)
我们的演示游戏(作为未来游戏开发者的参考)包含以下权限:
<uses-permission android:name="com.identifier.gamecenterapp.contentprovider.READ_DATABASE"/>
<uses-permission android:name="com.identifier.gamecenterapp.contentprovider.WRITE_DATABASE"/>
Run Code Online (Sandbox Code Playgroud)
现在 - 每当我们尝试使用游戏访问提供程序时,都会收到以下错误:
09-17 12:15:52.221: E/AndroidRuntime(4551): FATAL EXCEPTION: main
09-17 12:15:52.221: E/AndroidRuntime(4551): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.identifier.gamecenter.gctictactoe/com.identifier.gamecenter.game.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072
09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Handler.dispatchMessage(Handler.java:99)
09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Looper.loop(Looper.java:137)
09-17 12:15:52.221: …Run Code Online (Sandbox Code Playgroud) permissions android android-contentprovider android-4.3-jelly-bean
我正面临着AWSS3的一个奇怪问题.
建立:
- > Cognito,Dynamo甚至S3(通过cognito用户数据)工作.
但是我现在尝试使用以下代码直接连接到AWS3:"
let transferManager = AWSS3TransferManager.default()
let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest?.bucket = "XXXXXXXXXXXX"
uploadRequest?.key = "user-data/" + awsId! + "/primary_profile_picture.png"
uploadRequest?.body = imgUrl as URL
transferManager.upload(uploadRequest!).continueWith(executor: AWSExecutor.mainThread(), block: { (task:AWSTask<AnyObject>) -> Any? in
if let error = task.error as? NSError {
if error.domain == AWSS3TransferManagerErrorDomain, let code = AWSS3TransferManagerErrorType(rawValue: error.code) {
switch code {
case .cancelled, .paused:
break
default:
print("Error uploading: \(uploadRequest?.key) Error: \(error)")
}
} else {
print("Error uploading: …Run Code Online (Sandbox Code Playgroud) 我已经开始在我的项目中添加更多语言,并且本地化的字符串和图形没有太多麻烦.
我有一个最后一个问题,它是一个plist文件.
此plist文件包含应用程序的默认类别名称,并在字典中填充英文字符串.
我的问题是:有没有办法本地化plist文件?我虽然要向plist添加本地化字符串,但无法弄清楚如何.
我不想在代码中决定使用plist文件,因为默认的plist文件在首次使用时被用户覆盖.
我正在为iOS编写一个小型通用游戏.高分将通过iCloud Key/Value商店在设备上同步.
获得最新分数:
func retrieveHighestScore() -> Int64 {
let iCloudScore: Int64 = NSUbiquitousKeyValueStore.defaultStore().longLongForKey(KeyValueKeyClassification.KeyHighscore.toRaw())
let localScore: Int64 = Int64(NSUserDefaults.standardUserDefaults().integerForKey(KeyValueKeyClassification.KeyHighscore.toRaw()))
var result: Int64 = 0
if localScore > iCloudScore {
storeNewHighscore(localScore)
result = localScore
} else {
storeNewHighscore(iCloudScore)
result = iCloudScore
}
return result
}
Run Code Online (Sandbox Code Playgroud)
存储新的高分
func storeNewHighscore(newScore: Int64) {
NSUbiquitousKeyValueStore.defaultStore().setLongLong(newScore, forKey: KeyValueKeyClassification.KeyHighscore.toRaw())
NSUserDefaults.standardUserDefaults().setInteger(Int(newScore), forKey: KeyValueKeyClassification.KeyHighscore.toRaw())
if NSUbiquitousKeyValueStore.defaultStore().synchronize() {
println("Synched Successfully")
}
}
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,分数不同步.
我总是得到当前设备的最高分,而不是其他设备.
原因可能在于itunesconnect还是我的代码有问题?我正在使用ipad和iphone进行测试,两者都登录到我自己的icloud帐户.
我正在注册这样的更改:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override …Run Code Online (Sandbox Code Playgroud) 我有一个(可以)简单的修复我的coredata持久性商店的问题.
我创建它:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (persistentStoreCoordinator != nil)
{
return persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"dummyURL.sqlite"];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return persistentStoreCoordinator;
}
Run Code Online (Sandbox Code Playgroud)
使用网址 dummyURL.sqlite
我在使用该项目的第一天就这样做了,并且忘记了重命名..现在我所有现有的测试设备(4)都在使用超过2个月,使用该应用程序,收集大量数据并存储它一个愚蠢的网址^^
更新我做了一些关于持久性存储迁移的研究并编写了这个函数:
-(void)migrate{
NSPersistentStoreCoordinator *psc = [self.dataHandler.managedObjectContext persistentStoreCoordinator];
NSURL *oldURL = [psc URLForPersistentStore:[[psc persistentStores]objectAtIndex:0]];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSURL *newURL = [[appDelegate applicationDocumentsDirectory] URLByAppendingPathComponent:@"database.sqlite"]; …Run Code Online (Sandbox Code Playgroud) 我正在使用markdown pro(http://www.markdownpro.com/)编写一些降价文档
不知何故,并非我添加的所有图像都显示在最终文档中:
我这样添加它们
<img src="./img/clv.png" height="100"/>
Run Code Online (Sandbox Code Playgroud)
但结果看起来是这样的

文件结构如下所示:

而“summary”是我的 .md 文件
我也尝试过 markdown 语法

Run Code Online (Sandbox Code Playgroud)
和明确的结束标签
<img></img>
Run Code Online (Sandbox Code Playgroud)
但总是得到相同的结果,没有显示图像。
我尝试过的其他方法:
<img src="./img/clv.png" height="100"/>
<img src="../img/clv.png" height="100"/>
<img src="img/clv.png" height="100"/>
<img src="~/img/clv.png" height="100"/>
Run Code Online (Sandbox Code Playgroud)
结果:

ios ×5
swift ×4
objective-c ×3
xcode ×2
amazon-s3 ×1
amazon-sns ×1
android ×1
core-data ×1
enums ×1
grails ×1
grails-orm ×1
hibernate ×1
html ×1
icloud ×1
ios8 ×1
iphone ×1
localization ×1
markdown ×1
permissions ×1
plist ×1
random ×1
tableview ×1
uitableview ×1