cocoa-touch

KVO on an NSCountedSet?

落爺英雄遲暮 提交于 2020-01-01 06:18:43
问题 I'd like to monitor an NSCountedSet to see if its contents changes. Setting up KVO seems to compile but it's not being triggered. First question: can you observe a set? If so then is there something wrong with this message? [subViewA addObserver:subViewB forKeyPath:@"countedSet" options:0 context:NULL]; I'm really just trying to monitor the count of (number of objects in) the set if that helps. Edit - here's the observer (subViewB): - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:

Error trying to assigning __block ALAsset from inside assetForURL:resultBlock:

送分小仙女□ 提交于 2020-01-01 06:05:27
问题 I am trying to create a method that will return me a ALAsset for a given asset url. (I need upload the asset later and want to do it outside the result block with the result.) + (ALAsset*) assetForPhoto:(Photo*)photo { ALAssetsLibrary* library = [[[ALAssetsLibrary alloc] init] autorelease]; __block ALAsset* assetToReturn = nil; NSURL* url = [NSURL URLWithString:photo.assetUrl]; NSLog(@"assetForPhoto: %@[", url); [library assetForURL:url resultBlock:^(ALAsset *asset) { NSLog(@"asset: %@",

iOS 7: UIWebView crashes because of range exception

落爺英雄遲暮 提交于 2020-01-01 05:50:22
问题 I'm currently building an App that uses the krpano viewer, which is a Panorama Viewer built with JavaScript. I'm loading this Panorama viewer in a UIWebView with local images that are saved on the iPad. But after using the Panorama viewer for a while, I get this error and the app crashes: Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[WebCoreSharedBufferData getBytes:range:]: range {0, 4000} exceeds data length 0' *** First throw call stack: (0x2e213f53

Reopening AVCaptureSession

只愿长相守 提交于 2020-01-01 05:48:10
问题 I have an application which takes some pictures. My whole application is based on the AVCam sample code from WWDC 2010. I've messed with it a lot and yet, up until now I can't figure out how to release the camera view properly which releases the camera session... All i'm trying to do is the following: Open camera view controller Take some photos Close camera view Controller Open it again The second time I push the viewController the session is lost, preview is not available and capturing is

iPhone Core Data Example produces exception

一个人想着一个人 提交于 2020-01-01 05:47:11
问题 No longer under NDA. There was an ommision in the iPhone Core Data example, but is now corrected. Also the sample code was always correct, they just left out some details in the tutorial. (Please refer to iPhone Dev Forums for explanation) I built an app twice and received the same error twice (but in 2 different places): Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Event'' I

Implement a Debounced/Coalesced Pattern in Cocoa Touch like `layoutSubviews`

放肆的年华 提交于 2020-01-01 05:16:08
问题 A number of Cocoa Touch classes leverage a design pattern of coalescing events. UIViews , for example, have a method setNeedsLayout which causes layoutSubviews to be called in the very near future. This is especially useful in situations where a number of properties influence the layout. In the setter for each property you can call [self setNeedsLayout] which will ensure the layout will be updated, but will prevent many (potentially expensive) updates to the layout if multiple properties are

Why is this over-releasing? UINavigationController / UITableview

别来无恙 提交于 2020-01-01 04:53:06
问题 I'm pushing a view controller onto my navigation controller's stack from within my TableViewController's didSelectRowAtIndexPath method as so: MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; MyObject *myO = (MyObject *)[appDelegate.myOs objectAtIndex:indexPath.row]; myViewController.amount = myO.amount; [self.navigationController

UISegmentedControl custom background image

雨燕双飞 提交于 2020-01-01 04:50:11
问题 I have UINavigationBar setup as image - some wood texture. I want to insert UISegmentedControl with 4 buttons on that bar. Buttons should have same texture with slightly changed tint. One solution would be to change tint alpha of buttons background color, so that texture in background can get trough, but as I set alpha for tint in IB it doesn't save value, it always gets back to value 1. I cant get UISegmentedControl to show background image, so finally gave up and decide to search for help..

Problem detecting if UITableView has scrolled to the bottom

て烟熏妆下的殇ゞ 提交于 2020-01-01 04:44:04
问题 I'm using the following code to detect if I've reached the bottom of a UITableView - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if(self.tableView.contentOffset.y >= (self.tableView.contentSize.height - self.tableView.bounds.size.height)) { NSLog(@"bottom!"); NSLog(@"%@", [self getLastMessageID]); [self getMoreStuff:[self getLastMessageID]]; } } This works fine, but the only problem is when the user is pulling the tableview down (like pull to refresh) the code fires. How can I

iOS 8 GM does not update constraints on collection views

冷暖自知 提交于 2020-01-01 04:13:09
问题 In Xcode 6 Beta 7 and all versions before it, I had a collection view that would update its constraints on its cells when an iPad would rotate between landscape and portrait. Now, it doesn't update at all, and in fact it looks exactly like how I leave it in the XIB, which implies to me that it's not updating at all. It appears that the reusable views I'm using are updating correctly, but the cells certainly are not. Has anyone else run into this issue yet? Anyone have any ideas for how to get