UISCROLLVIEW

平成26年9月19日(火曜日)
画像(Image View)を背景とした場合の措置

  • Scroll View追加
  • その下位にView追加
  • Scroll View→add New constrain (上下左右 0 0 0 0)
  • 以下 上下のみに設定 ERRORの喚起あれど、今回のこのまま
  • View→ add New constrain (上下のみ 0 0 )
  • View→ width,height設定
  • View→Center X Alignment設定

文字列比較

[objc]
NSString *str1 = @"ABC";
NSString *str2 = @"ABC";

// 同じ文字列かを判定
if ([str1 isEqualToString:str1]) {
NSLog(@"同じ文字列です");
} else {
NSLog(@"異なる文字列です");
}
[/objc]

SearchBar

SearchBarの遷移先でObjectを変更すると、エラーになる件。
ERROR
2014-09-07 13:05:38.832 BeppuSpa88[13043:60b] mainview coredata exist don’t anything!!
2014-09-07 13:05:46.250 BeppuSpa88[13043:60b] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:1352
2014-09-07 13:05:46.262 BeppuSpa88[13043:60b] CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of sections. The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (11), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted). with userInfo (null)

[objc]
//
@property Boolean IsSearchTable;
//
[/objc]

[objc]
//
@synthesize IsSearchTable;
//
[/objc]

NORMAL VIEW か SEARCHBARか確認した上で処理することで対応。

[objc]
//
//—————————————————————————-
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {
if(sender == self.searchDisplayController.searchResultsTableView) {
// サーチビュー
NSIndexPath *indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
[[segue destinationViewController] setDetailItem:object];

//SearchBarの遷移先でObjectを変更すると、エラーになる件についての対策
[[segue destinationViewController] setIsSearchTable:YES];
}
else {
// ノーマルビュー
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
[[segue destinationViewController] setDetailItem:object];

//SearchBarの遷移先でObjectを変更すると、エラーになる件についての対策
[[segue destinationViewController] setIsSearchTable:NO];
}
} else if ([[segue identifier] isEqualToString:@"showflip"]) {
[[segue destinationViewController] setDelegate:self];

// 現在のFetche_predicate_strをflipviewに通知。
[[segue destinationViewController] setFlipout_str:Fetche_predicate_str];
}
}
//—————————————————————————-
//
[/objc]

[objc]
//
//動作確認用
NSLog(@"IsSearchTable = %hhu",IsSearchTable);
//self.title=[NSString stringWithFormat:@"%@",[[_detailItem valueForKey:@"name"] description]];
//温泉入湯チェックボタン追加 of_off
//SearchBarにより遷移するとERROR発生。さて…とりあえずコメントアウト次なる手を。。。
//次の一手
if (IsSearchTable == NO) {
[_detailItem setValue:[NSNumber numberWithBool:YES] forKey:@"on_off"];
}
//—————————–
//
[/objc]

平成26年9月7日(日曜日)

DetailTableViewを非table版に変更。

segue → showDetail(push)

SearchBarの遷移先でObjectを変更すると、エラーになる件。
ERROR
2014-09-07 13:05:38.832 BeppuSpa88[13043:60b] mainview coredata exist don’t anything!!
2014-09-07 13:05:46.250 BeppuSpa88[13043:60b] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:1352
2014-09-07 13:05:46.262 BeppuSpa88[13043:60b] CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of sections. The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (11), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted). with userInfo (null)

解決済み、SEARCHBARカテゴリ参照。

他に、
ラベルに表示されない件について
detail viewのviewDidLoadに[self configureView]を追加して、解決。

[objc]
– (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self configureView];
_view2.backgroundColor=[UIColor colorWithRed:0.96 green:0.96 blue:0.86 alpha:0.3];
}
[/objc]

画面遷移の変更

[objc]
MapViewController.m
//
//DetailTableViewController *mycontroller = [self.storyboard instantiateViewControllerWithIdentifier:@"registered"];
DetailTableViewController *mycontroller = [self.storyboard instantiateViewControllerWithIdentifier:@"registered2"];
//
[/objc]

OSX

スクリーンショット

平成26年9月6日
command (⌘) + shift + 4」キーを押して、十字ポインタをドラッグして領域を選択します。「shift」「option」または「space」バーを押しながらドラッグして、選択した領域のサイズを変更します。取り消すには、マウスボタンを放す前に「escape (esc)」キーを押します。

特定のウインドウのスクリーンショット
「command (⌘) + shift + 4」キーを押して「space」バーを押し、カメラのポインタをウインドウの上に移動してハイライトし、クリックします。

iphone画面のコピー(スクリーンショット)
ホームボタンとスリープボタンを同時に押す。

COREDATA

平成26年9月6日

マイグレーション調査

[objc]
//
[newManagedObject setValue:[NSNumber numberWithBool:NO] forKey:@"on_off"];
//
[/objc]

平成26年9月5日

model変更(on_off追加)

[objc]
– (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
//modelを変更した場合の対処 その①
/*
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"WeatherForcaster01.sqlite"];
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];

if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}
*/

//model変更無し

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"WeatherForcaster01.sqlite"];

if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}

NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

//modelを変更した場合の対処 その② 実使用無し
//—————————-
// Check if we already have a persistent store
if ( [[NSFileManager defaultManager] fileExistsAtPath: [storeURL path]] ) {
NSDictionary *existingPersistentStoreMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType: NSSQLiteStoreType URL: storeURL error: &error];
if ( !existingPersistentStoreMetadata ) {
// Something *really* bad has happened to the persistent store
[NSException raise: NSInternalInconsistencyException format: @"Failed to read metadata for persistent store %@: %@", storeURL, error];
}

if ( ![self.managedObjectModel isConfiguration: nil compatibleWithStoreMetadata: existingPersistentStoreMetadata] ) {
if ( ![[NSFileManager defaultManager] removeItemAtURL: storeURL error: &error] )
NSLog(@"*** Could not delete persistent store, %@", error);
} // else the existing persistent store is compatible with the current model – nice!
} // else no database file yet
//—————————-

if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
/*
Replace this implementation with code to handle the error appropriately.

abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

Typical reasons for an error here include:
* The persistent store is not accessible;
* The schema for the persistent store is incompatible with current managed object model.
Check the error message to determine what the actual problem was.

If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application’s resources directory instead of a writeable directory.

If you encounter schema incompatibility errors during development, you can reduce their frequency by:
* Simply deleting the existing store:
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]

* Performing automatic lightweight migration by passing the following dictionary as the options parameter:
@{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES}

Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.

*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}

return _persistentStoreCoordinator;
}
[/objc]

UIBUTTON

平成26年9月5日

[objc]
– (void)awakeFromNib
{
// Initialization code
[self.switch_button setImage:[UIImage imageNamed:@"on.png"] forState:UIControlStateSelected];
[self.switch_button setImage:[UIImage imageNamed:@"off.png"] forState:UIControlStateNormal];
switch_button.selected = YES;
//switch_button.selected = NO;
}
[/objc]