Search Results

Search found 3754 results on 151 pages for 'ios simulator'.

Page 57/151 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • AVFoundation buffer comparison to a saved image

    - by user577552
    Hi, I am a long time reader, first time poster on StackOverflow, and must say it has been a great source of knowledge for me. I am trying to get to know the AVFoundation framework. What I want to do is save what the camera sees and then detect when something changes. Here is the part where I save the image to a UIImage : if (shouldSetBackgroundImage) { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); // Create a bitmap graphics context with the sample buffer data CGContextRef context = CGBitmapContextCreate(rowBase, bufferWidth, bufferHeight, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); // Create a Quartz image from the pixel data in the bitmap graphics context CGImageRef quartzImage = CGBitmapContextCreateImage(context); // Free up the context and color space CGContextRelease(context); CGColorSpaceRelease(colorSpace); // Create an image object from the Quartz image UIImage * image = [UIImage imageWithCGImage:quartzImage]; [self setBackgroundImage:image]; NSLog(@"reference image actually set"); // Release the Quartz image CGImageRelease(quartzImage); //Signal that the image has been saved shouldSetBackgroundImage = NO; } and here is the part where I check if there is any change in the image seen by the camera : else { CGImageRef cgImage = [backgroundImage CGImage]; CGDataProviderRef provider = CGImageGetDataProvider(cgImage); CFDataRef bitmapData = CGDataProviderCopyData(provider); char* data = CFDataGetBytePtr(bitmapData); if (data != NULL) { int64_t numDiffer = 0, pixelCount = 0; NSMutableArray * pointsMutable = [NSMutableArray array]; for( int row = 0; row < bufferHeight; row += 8 ) { for( int column = 0; column < bufferWidth; column += 8 ) { //we get one pixel from each source (buffer and saved image) unsigned char *pixel = rowBase + (row * bytesPerRow) + (column * BYTES_PER_PIXEL); unsigned char *referencePixel = data + (row * bytesPerRow) + (column * BYTES_PER_PIXEL); pixelCount++; if ( !match(pixel, referencePixel, matchThreshold) ) { numDiffer++; [pointsMutable addObject:[NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH - (column/ (float) bufferHeight)* SCREEN_WIDTH - 4.0, (row/ (float) bufferWidth)* SCREEN_HEIGHT- 4.0)]]; } } } numberOfPixelsThatDiffer = numDiffer; points = [pointsMutable copy]; } For some reason, this doesn't work, meaning that the iPhone detects almost everything as being different from the saved image, even though I set a very low threshold for detection in the match function... Do you have any idea of what I am doing wrong?

    Read the article

  • Monotouch.dialog and story board apps?

    - by Robin Diederen
    I'm trying to use mt.d; I've "drawn" an app using the storyboard feature of Xcode. My app consists of a tabbar which displays one of three viewcontrollers. Two out of three are simple viewcontrollers (single screens) and one is a splitviewcontroller. The splitview is tricky; using the stock xcode components I've drawn a master / table and a detail view. The table works as expected, but now I want to use mt.d to fill the detailview (later I need it to depend on the selection of the master, but not for now). I've subclassed the splitviewcontroller; in the viewdidload event I've created a mt.d dialogviewcontroller. Now I'm trying to push the dialogviewcontroller to the detailview, using the splitviewcontroller.viewcontrollers array. Doesn't seem to work; when running the app it still some an empty screen for the detail view (as drawn in xcode). Any clues for doing what I want? Thanx!

    Read the article

  • Swiping Images with Page Control in Iphone

    - by lakesh
    I am trying to make practice app where i can scroll images with page control. I am able to scroll images and able to include the page control. But the problem i face is i am not able to interlink the two. Meaning to say when I scroll the images, the page control is not affected and when i change the page control, the scrolling of the images is unaffected. I have referred to this: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ for the scrolling with page control. Viewcontroller.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIScrollViewDelegate>{ UIScrollView *scrollView; UIPageControl *pageControl; BOOL pageControlBeingUsed; } @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; @property (nonatomic, retain) IBOutlet UIPageControl *pageControl; - (IBAction)changePage; @end Viewcontroller.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize scrollView,pageControl; - (void)viewDidLoad { [super viewDidLoad]; NSArray *images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.jpeg"],[UIImage imageNamed:@"2.jpeg"],[UIImage imageNamed:@"3.jpeg" ], nil]; self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * images.count, self.scrollView.frame.size.height); for (int i = 0; i < images.count; i++) { CGRect frame; frame.origin.x = self.scrollView.frame.size.width * i; frame.origin.y = 0; frame.size = self.scrollView.frame.size; UIImageView* imgView = [[UIImageView alloc] init]; imgView.image = [images objectAtIndex:i]; imgView.frame = frame; [scrollView addSubview:imgView]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.scrollView = nil; } - (void)scrollViewDidScroll:(UIScrollView *)sender { // Update the page when more than 50% of the previous/next page is visible CGFloat pageWidth = self.scrollView.frame.size.width; int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; self.pageControl.currentPage = page; } - (IBAction)changePage{ // update the scroll view to the appropriate page CGRect frame; frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage; frame.origin.y = 0; frame.size = self.scrollView.frame.size; [self.scrollView scrollRectToVisible:frame animated:YES]; pageControlBeingUsed = YES; } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { pageControlBeingUsed = NO; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { pageControlBeingUsed = NO; } @end Need some guidance on this... Thanks..

    Read the article

  • Change text of UIAlertView when recording a video with UIImagePickerController and reaching the videoMaximumDuration

    - by aimak
    I'd want to know how to change to text of the UIAlertView appearing when I record a video with a UIImagePickerController and I reach the videoMaximumDuration. If it is not possible to change the text of that UIAlertView, is it at least possible to display it in another language ? Edit : the default text is "The maximum length for this video has been reached" with title "Video Recording Stopped". Thank you, aimak

    Read the article

  • NSDateFormatterFullStyle without year (NSDateFormatter)

    - by Brian Halpin
    Using the user's currentLocale from the device, I want to have a date format exactly like the one generated for NSDateFormatterFullStyle minus the year: [dateFormatter setDateStyle:NSDateFormatterFullStyle]; Friday, 21 September (2012) I've noticed the iPhone app, Living Earth does this and works for all locales, so does the iPhone lock screen. A custom formatter such as, [dateFormatter setDateFormat:@"EEEE, MMMM"]; won't change with localisation. Can anyone shed some light on how to accomplish this? None of the options for date style seem to do this. Thanks

    Read the article

  • RestKit : Not able to perform mapping using coredata

    - by Ashish Beuwria
    I'm using rest kit 0.20.3 and Xcode 5. Without core data I'm able to perform all rest kit operation, but when I've tried it with core data, I'm not even able to perform GET due to some problem. I can't figure it out. I'm new with core data. So pls help. Here is my code: AppDelegate.m @implementation CardGameAppDelegate @synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RKLogConfigureByName("RestKit", RKLogLevelWarning); RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace); RKLogConfigureByName("RestKit/Network", RKLogLevelTrace); RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://192.168.1.3:3010/"]]; RKManagedObjectStore *objectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:self.managedObjectModel]; objectManager.managedObjectStore = objectStore; RKEntityMapping *playerMapping = [RKEntityMapping mappingForEntityForName:@"Player" inManagedObjectStore:objectStore]; [playerMapping addAttributeMappingsFromDictionary:@{@"id": @"playerId", @"name": @"playerName", @"age" : @"playerAge", @"created_at": @"createdAt", @"updated_at": @"updatedAt"}]; RKResponseDescriptor *responseDesc = [RKResponseDescriptor responseDescriptorWithMapping:playerMapping method:RKRequestMethodGET pathPattern:@"/players.json" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [objectManager addResponseDescriptor:responseDesc]; PlayersTableViewController *ptvc = (PlayersTableViewController *)self.window.rootViewController; ptvc.managedObjectContext = self.managedObjectContext; return YES; } and code for playerTableViewController.h #import <UIKit/UIKit.h> @interface PlayersTableViewController : UITableViewController <NSFetchedResultsControllerDelegate> @property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController; @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext; @end and PlayerTableViewController.m get method: -(void)loadPlayers{ [[RKObjectManager sharedManager] getObjectsAtPath:@"/players.json" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){ [self.refreshControl endRefreshing]; } failure:^(RKObjectRequestOperation *operation, NSError *error) { [self.refreshControl endRefreshing]; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An Error Has Occurred" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; }]; } I'm getting the following error : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to perform mapping: No `managedObjectContext` assigned. (Mapping response.URL = http://192.168.1.3:3010/players.json)'

    Read the article

  • iPad start in Landscape receive only touch within 768x768

    - by user1307179
    It works perfect fine when starting in portrait and also works when you rotate from portrait to landscape and back. It does not work when starting in landscape. But then it works when you rotate from landscape to portrait and back. In landscape starting mode, the screen does not respond with any touch where screen coordinateX greater than 768. What happens in code is, I use status bar orientation to determine original orientation and rotate each view manually. The views display correctly but does not receive touch properly. Then my root view controller will get called when ipad start rotating with: - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration which will rotate every subviews. Root controller: - (void)loadView { self.view = [[UIView alloc]init ]; //initialize child views [self willRotateToInterfaceOrientation:0 duration:0]; } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if ([model isLandscape]) { self.view.frame = CGRectMake(0, 0, 1024, 768-80); } else { self.view.frame = CGRectMake(0, 0, 768, 1024-80); } //rotate child views } My code [model isLandscape] works so I don't need to provide details as to how it works but here are the code anyway: - (bool)isLandscape { if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) return true; else return false; } -(id) init { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; } - (void)orientationChanged:(NSNotification *)notification { UIInterfaceOrientation curOrientation = [[UIDevice currentDevice] orientation]; if (curOrientation == UIDeviceOrientationPortrait || curOrientation == UIDeviceOrientationPortraitUpsideDown || curOrientation == UIDeviceOrientationLandscapeLeft || curOrientation == UIDeviceOrientationLandscapeRight) { orientation = curOrientation; ((AppDelegate*)([UIApplication sharedApplication].delegate)).savedOrientationForRestart = orientation; NSLog(@"changed"); } } -(void)validateOrientation { //first time when initializing orientation UIInterfaceOrientation curOrientation = [[UIDevice currentDevice] orientation]; if (curOrientation != UIDeviceOrientationPortrait && curOrientation != UIDeviceOrientationPortraitUpsideDown && curOrientation != UIDeviceOrientationLandscapeLeft && curOrientation != UIDeviceOrientationLandscapeRight) { orientation = [[UIApplication sharedApplication] statusBarOrientation]; } }

    Read the article

  • https google urlshortener request missing body

    - by Peter
    Hi, Just trying to get the new API for the goo.gl URL shortening service working on my iPhone, following the instructions on http://code.google.com/apis/urlshortener/v1/getting_started.html I'm set up and the API is enabled etc., but when I send a request in the recommended format: POST https://www.googleapis.com/urlshortener/v1/url Content-Type: application/json {"longUrl": "http://www.google.com/"} I get an error returned. The error is exactly the one listed on that page in the errors section for if you haven't passed in a longURL param. This makes me think that I'm not setting up the body of the POST request properly. Here's the code if you have any pointers... NSString *longURLString=@"http://www.stackoverflow.com"; NSString *googlRequestString=@"https://www.googleapis.com/urlshortener/v1/url"; NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:googlRequestString]]; [request setHTTPMethod:@"POST"]; [request addValue:@"application/json" forHTTPHeaderField:@"Content-Type:"]; NSString *bodyString=[NSString stringWithFormat:@"{\"longUrl\": \"%@\"}",longURLString]; [request setHTTPBody:[bodyString dataUsingEncoding:NSUTF8StringEncoding]]; NSURLResponse *theResponse; NSError *error=nil; NSData *receivedData=[NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&error]; NSString *receivedString=[[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding]; NSLog(@"Received data: %@",receivedString); [receivedString release]; The NSLog returns: Received data: { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Required", "locationType": "parameter", "location": "resource.longUrl" } ], "code": 400, "message": "Required" } } which is exactly what Google says you get if you have not passed a longUrl parameter.... My guess is I'm missing something very obvious here :-) P

    Read the article

  • Unbalanced calls to begin/end appearance transitions for <ViewController>,<Tab>

    - by onkar
    I am trying to implement Tabs into my secondView.On button touch(from ViewController.m) I am navigating to secondView(Tabs). In my Tabs.xib file I have added a TabBar at bottom and it is custom class of UITabBar. ViewController.m - (IBAction)touchedInside:(id)sender { NSLog(@"touhced up inside"); Tabs *temp = [[Tabs alloc]initWithNibName:@"Tabs" bundle:nil]; [self.navigationController pushViewController:temp animated:YES]; [self presentViewController:temp animated:YES completion:nil]; } Tabs.m - (void)viewDidLoad { [super viewDidLoad]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; UITabBarController *tabBarController = [[UITabBarController alloc]init]; /* Tab_1 *firstView = [[Tab_1 alloc] init]; UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"First" image:nil tag:1]; [firstView setTabBarItem:item1]; NSLog(@"after first tab is added"); Tab_2 *secondView = [[Tab_2 alloc] init]; UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"Sec" image:nil tag:1] ; [secondView setTabBarItem:item2]; NSLog(@"after second tab is added"); [tabBarController setViewControllers:[NSArray arrayWithObjects:firstView,secondView,nil] animated:NO]; NSLog(@"after tab is added"); [appDelegate.window addSubview:tabBarController.view]; NSLog(@"after view is added"); */ appDelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. UIViewController *viewController1 = [[Tab_1 alloc] initWithNibName:@"Tab 1" bundle:nil]; UIViewController *viewController2 = [[Tab_2 alloc] initWithNibName:@"Tab 2" bundle:nil]; UIViewController *viewController3 = [[Tab_2 alloc] initWithNibName:@"Tab 1" bundle:nil]; tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil]; appDelegate.window.rootViewController = self.tabBarController; [appDelegate.window makeKeyAndVisible]; Tabs *temp = [[Tabs alloc]initWithNibName:@"Tabs" bundle:nil]; [self.navigationController presentModalViewController:temp animated:NO]; } Errors Unbalanced calls to begin/end appearance transitions for <ViewController: 0x6833c80>. 2012-12-06 09:57:48.963 demoTabs[667:f803] Unbalanced calls to begin/end appearance transitions for <Tabs: 0x6a3fc90>.

    Read the article

  • Comparing UIColors or CGColor or CGColorSpace

    - by wiznaibus
    I'm having an issue comparing UIColors. I have an image, which I have successfully extracted the color on the image at which the user clicked. Now I want to compare that color with other colors, but I'm getting some strange results. Here's what I've tried: CGColorRef pixelColor = [[buttonImage colorAtPixel:point] CGColor]; UIColor* color = [UIColor colorWithCGColor:pixelColor]; UIColor* aqua = [UIColor colorWithRed:0.521569 green:0.768627 blue:0.254902 alpha:1]; if (CGColorEqualToColor(color.CGColor, aqua.CGColor)) { DLog(@"Apparently, it works"); } DLog(@"%@", color.CGColor); DLog(@"%@", aqua.CGColor); Output: 2011-05-21 19:48:27.144 Coffee[66860:207] -[DescriptorsViewController touchesEnded:withEvent:] <CGColor 0x4d1eb80> [<CGColorSpace 0x4d1a070> (kCGColorSpaceDeviceRGB)] ( 0.521569 0.768627 0.254902 1 ) 2011-05-21 19:48:27.145 Coffee[66860:207] -[DescriptorsViewController touchesEnded:withEvent:] <CGColor 0x4d1f750> [<CGColorSpace 0x4d1a070> (kCGColorSpaceDeviceRGB)] ( 0.521569 0.768627 0.254902 1 ) It looks like the CGColor addresses are different, but the CGColorSpaces are the same, but I can't figure out how to compare the CGColorSpaces I've also tried this: CGColorRef pixelColor = [[buttonImage colorAtPixel:point] CGColor]; UIColor* color = [UIColor colorWithCGColor:pixelColor]; UIColor* aqua = [UIColor colorWithRed:0.521569 green:0.768627 blue:0.254902 alpha:1]; if ([color isEqual:aqua]) { DLog(@"Apparently, it works"); } DLog(@"%@", color.CGColor); DLog(@"%@", aqua.CGColor); The same silliness occurs. 2011-05-21 20:02:49.277 Coffee[67013:207] -[DescriptorsViewController touchesEnded:withEvent:] <CGColor 0x4d3b810> [<CGColorSpace 0x5912010> (kCGColorSpaceDeviceRGB)] ( 0.521569 0.768627 0.254902 1 ) 2011-05-21 20:02:49.278 Coffee[67013:207] -[DescriptorsViewController touchesEnded:withEvent:] <CGColor 0x4d3ba20> [<CGColorSpace 0x5912010> (kCGColorSpaceDeviceRGB)] ( 0.521569 0.768627 0.254902 1 )`

    Read the article

  • Setting the background colour/highlight colour for a given string range using Core Text

    - by Jasarien
    I have some text laid out using Core Text in my iPhone app. I'm using NSAttributedString to set certain styles within the text for given ranges. I can't seem to find an attribute for setting a background / highlight colour, though it would seem it is possible. I couldn't find an attribute name constant that sounded relevant and the documentation only lists: kCTCharacterShapeAttributeName kCTFontAttributeName kCTKernAttributeName kCTLigatureAttributeName kCTForegroundColorAttributeName kCTForegroundColorFromContextAttributeName kCTParagraphStyleAttributeName kCTStrokeWidthAttributeName kCTStrokeColorAttributeName kCTSuperscriptAttributeName kCTUnderlineColorAttributeName kCTUnderlineStyleAttributeName kCTVerticalFormsAttributeName kCTGlyphInfoAttributeName kCTRunDelegateAttributeName Craig Hockenberry, developer of Twitterrific has said publicly on Twitter that he uses Core Text to render the tweets, and Twitterrific has this background / highlight that I'm talking about when you touch a link. Any help or pointers in the right direction would be fantastic, thanks. Edit: Here's a link to the tweet Craig posted mentioning "Core text, attributed strings and a lot of hard work", and the follow up that mentioned using CTFrameSetter metrics to work out if touches intersect with links.

    Read the article

  • Image Drawing on UIView

    - by user1180261
    I'm trying to create an application where I can draw a lot of pictures at a specific point (determined for each image) on one view. I have a coordinates where I need draw a picture, width and height of it For example: I have 2 billion jpeg's images. for each images I have a specific origin point and size. In 1 second I need draw on view 20-50 images in specific point. I have already tryid solve that in the next way: UIGraphicsBeginImageContextWithOptions(self.previewScreen.bounds.size, YES, 0); [self.previewScreen.image drawAtPoint:CGPointMake(0, 0)]; [image drawAtPoint:CGPointMake(nRect.left, nRect.top)]; UIImage *imagew = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self.previewScreen setImage:imagew]; but in this solution I have a very big latency with displaying images and big CPU usage WBR Maxim Tartachnik

    Read the article

  • Check if UINavigationItem title is truncated

    - by PartiallyFinite
    I want to check whether the title of a UINavigationItem is truncated. I set the title like this: self.navigationItem.title = whatever. I know I can check if the text in a UILabel is truncated like this: CGSize size = [label.text sizeWithFont:[UIFont fontWithName:@"myfont" size:18.0]]; if (size.width > label.bounds.size.width) { // set a shorter title } And I can even find the UINavigationItemView object in which the title is displayed like so: UIView *navItemView; for (UIView *view in self.navigationController.navigationBar.subviews) { if ([view isKindOfClass:NSClassFromString(@"UINavigationItemView")]) { navItemView = view; } } But I cannot apply this method to the navItemView because is always seems to have a width of exactly 58, which is much less than the title in it, so according to that, it would appear that the title is truncated, even when it isn't. So, my question comes down to this: How do I find the width of the title displayed in the UINavigationItem? UPDATE: I have found a solution to my problem, but it isn't exactly ideal, perfect, or reliable, so I am not marking it as an answer yet. If anyone has any better solutions, please share them.

    Read the article

  • Custom UITableviewcell shows "fatal error: Can't unwrap Optional.None" issue in swift

    - by user1656286
    I need to load a custom cell in a UITableView. I created a custom subclass of UITableViewCell named "CustomTableViewCell". I have added a UITabelViewCell to the tableview (using drag and drop) as shown in figure. Then in file inspector I set the class of that UITabelViewCell to be "CustomTableViewCell". Here is my code: class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { @IBOutlet var tableView : UITableView var items = String[]() override func viewDidLoad() { super.viewDidLoad() items = ["Hi","Hello","How"] self.tableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: "CusTomCell") // Do any additional setup after loading the view, typically from a nib. } func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{ return items.count } func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{ var cell:CustomTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("CusTomCell") as CustomTableViewCell cell.labelTitle.text = items[indexPath.row] return cell; } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } When I run my code, I get the following error: "fatal error: Can't unwrap Optional.None" as seen in the image.

    Read the article

  • Sort NSArray of custom objects based on sorting of another NSArray of strings

    - by Nic Hubbard
    I have two NSArray objects that I would like to be sorted the same. One contains NSString objects, the other custom Attribute objects. Here is what my "key" NSArray looks like: // The master order NSArray *stringOrder = [NSArray arrayWithObjects:@"12", @"10", @"2", nil]; The NSArray with custom objects: // The array of custom Attribute objects that I want sorted by the stringOrder array NSMutableArray *items = [[NSMutableArray alloc] init]; Attribute *attribute = nil; attribute = [[Attribute alloc] init]; attribute.assetID = @"10"; [items addObject:attribute]; attribute = [[Attribute alloc] init]; attribute.assetID = @"12"; [items addObject:attribute]; attribute = [[Attribute alloc] init]; attribute.assetID = @"2"; [items addObject:attribute]; So, what I would like to do is use the stringOrder array to determine the sorting of the items array of custom objects. How can I do this?

    Read the article

  • Core-Data + AFNetworking + UI Updating (Responsiveness)

    - by Mustafa
    Here's the scenario: I'm writing a DownloadManager, that allows the user to download, pause, cancel, download all, and pause all. The DownloadManager is a singleton, and uses AFNetworking to download files. It has it's own private managed object context, so that user can freely use other parts of the application (by adding, editing, deleting) core-data objects. I have a core-data entity DownloadInfo that stores the download information i.e. fileURL, fileSize, bytesRead, etc. The DownloadManager updates the download progress in DownloadInfo (one for each file). I have a DownloadManagerViewController which uses NSFetchedResultsController to show the download status to the user. This download view controller is using the main managed object context. Now let's say that I have 20 files in the download queue. And let's say that only 3 concurrent downloads are allowed. The download manager should download the file, and show the download progress. Problem: The DownloadInfo objects are being updated by the DownloadManager at a very high rate. The DownloadManagerViewController (responsible for showing the download progress) is updating the list using NSFetchedResultsControllerDelegate methods. The result is that a lot is happening in the main queue and application has very poor responsiveness. How can I fix this? How can I make the application responsive, while showing the download progress? I don't know how else to communicate that the download status between DownloadManager and DownloadManagerViewController. Is there another/ a better way to do this? I don't want to use main managed object context in my DownloadManager, for reasons mentioned above. Note, that the DownloadManager is using AFNetworking which is handling the requests asynchronously, but eventually the DownloadInfo objects are updated in the main thread (as a result of the callback methods). Maybe there's a way to handle the downloads and status update operations in a background thread? but how? How will I communicate between the main thread and the background thread i.e. how will I tell the background thread to queue another file for download? Thanks.

    Read the article

  • Monotouch Binding to Linea Pro SDK

    - by jeffrapp
    I'm trying to create a binding to the Linea Pro (it's the barcode scanner they use in the Apple Stores, Lowes) SDK. I'm using David Sandor's bindings as a reference, but the SDK has been updated a few times since January of 2011. I have most everything working, except for the playSound call, which is used to, well, play a sound on the Linea Pro device. The .h file from the SDK has the call as follows: -(BOOL)playSound:(int)volume beepData:(int *)data length:(int)length error:(NSError **)error; I've tried using int[], NSArray, and an IntPtr to the int[], but nothing seems to work. The last unsuccessful iteration of my binding looks like: [Export ("playSound:beepData:length:")] void PlaySound (int volume, NSArray data, int length); Now, this doesn't work at all. Also note that I have no idea what to do with the error:(NSError **)error part, either. I am lacking some serious familiarity with C, so any help would be extremely appreciated.

    Read the article

  • What's wrong with how I'm using NSDateFormatter?

    - by Thom Mahoney
    dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]; [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss zzz"]; NSString dateString = @"Tue, 08 Jun 2010 17:00:00 EDT"; NSDate eventDate = [dateFormatter dateFromString:dateString]; In this case the eventDate object is nil. Can somebody clue me in? This code used to work.

    Read the article

  • Jwplayer 6: html5 fullscreen when video clicked to play

    - by caaruiz
    I want to be able to use jwplayer so that when the user clicks on the video the video will start to play in fullscreen mode. I want this functionality to work on mobile devices that support html5. If the video is played on a mobile device it will take up the whole screen. Youtube and Vimeo currently do this on mobile devices. The Link Below uses Html5 video tag, which plays in fullscreen on mobile device when the video is clicked on. The only way I that I know that jwplayer allows fullscreen is that I manually click on the fullscreen button, but it would be nice to only click on the video to trigger the video to play in full screen.

    Read the article

  • How to bind Data to Dropdownlist in Kendo Ui Mobile

    - by dinesh Haraveer
    I have been using Kendo Mobile to develop an application, previously same application i have done in Kendo web,it's works fine.The main problem is that i have to bind data to two dropdownlist which the below code i have written,when my application is running it show an error like "Microsoft JScript runtime error: Object doesn't support property or method 'append'". in HTML <div id="forms" data-role="view" data-title="Form Elements" data-init="initForm"> <table> <tr> <td> <label style="margin-left: 20px"> Company:</label> </td> <td> <select id="ddlCompany" style="width: 200px"> <option>Select Company</option> </select> </td> <td class="style1"> <label style="margin-left: 20px"> Category:</label> </td> <td> <select id="ddlCategory" style="width: 200px"> <option>Select Category</option> </select> </td> <td> <label style="margin-left: 20px"> Product :</label> </td> <td> <select id="ddlProduct" style="width: 200px"> <option>Select Product</option> </select> </td> </tr> </table> </div> function initForm() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "FlashReportMobileWebService.asmx/GetCompany", dataType: "json", success: function (data) { for (i = 0; i < data.d.length; i++) { ddlCompany.append($("<option></option>").val(data.d[i].Company).html(data.d[i].Company)); }; $("#ddlCompany").kendoDropDownList(); } }); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "FlashReportMobileWebService.asmx/ToCategoryDropDown", dataType: "json", success: function (data) { for (i = 0; i < data.d.length; i++) { ddlCategory.append($("<option></option>").val(data.d[i].Category).html(data.d[i].Category)); }; $("#ddlCategory").kendoDropDownList(); }, failure: function (msg) { alert(msg); } }); } $("#ddlCategory").change( function (e) { var ddlProduct= $("#ddlProduct"); var dataItem = $("#ddlCategory").val(); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: "{'Category':'" + dataItem + "'}", url: "FlashReportWebService.asmx/ToFillProductDropDown", dataType: "json", success: function (data) { ddlProduct.empty(); for (i = 0; i < data.d.length; i++) { ddlProduct.append($("<option></option>").val(data.d[i].ProductName).html(data.d[i].ProductName)); }; $("#ddlProduct").kendoDropDownList(); }, failure: function (msg) { alert(msg); } }); }); var app = new kendo.mobile.Application(document.body); thanks for reading this

    Read the article

  • How do I blur (ios7 style) a section of an image in a UITableViewCell?

    - by George McKibbin
    I've got a UIImageView that takes up the whole cell and shows an image. I'd like to blur the bottom third of the view in the iOS7 style (we're targeting iOS7). There will be a label over the blurred part. The issue seems to be that I can't "screenshot" the UIImageView right as I am setting up the cell in tableView:cellForRowAtIndexPath: as it hasn't loaded yet. Although i've even tried setting up a timer for a 0.1 second delay and that also doesn't work. I've tried the stuff on http://damir.me/posts/ios7-blurring-techniques I've tried https://github.com/justinmfischer/7blur I'd like to use the new screenshotting API drawViewHierarchyInRect:afterScreenUpdates: I'd also like to use apple's sample code UIImage+ImageEffects The only thing that has worked so far has been to just put a UIToolbar in but the performance is really slow. I don't need dynamic updates. I've managed to get the following effect a few times but it has just tinted the view and hasn't actually blurred anything so I'm a bit confused.

    Read the article

  • How to set parameters of CGContextAddArcToPoint method using a slider

    - by Manish Sahni
    am making an app in which i have to control a smile of a face like graphics. For example if i slide the slider down(to a value less than middle) it should give the arc a sad face(like :-( ) effect and if i slide the slider up the arc should give the effect of smile(like :-) ).initially lips are like :-| . I need to control the lips which is an arc using a slider? smileSliderViewController.h #import <UIKit/UIKit.h> @interface smileSliderViewController : UIViewController { IBOutlet UISlider *slider; } -(IBAction)valueChange:(id)sender; @end smileSliderViewController.m #import "smileSliderViewController.h" //#import "smile.h" @implementation smileSliderViewController -(IBAction)valueChange:(id)sender { int value = (int)(slider.value); if(value>0 && value<25) { //value--; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); CGFloat components[] = {0.0,0.0,1.0,1.0}; CGColorRef color = CGColorCreate(colorspace, components); CGContextSetStrokeColorWithColor(context, color); CGContextMoveToPoint(context, 120,180); CGContextAddArcToPoint(context, 190 , 170, 270, 200, 0 ); CGContextStrokePath(context); } } smile.h #import <UIKit/UIKit.h> #import "smile.m" @interface smile : UIView { IBOutlet UISlider *slider; } @end smile.m #import "smile.h" #import "smileSliderViewController.h" @implementation smile - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); //CGContextSetStrokeColor(context, [UIColor redColor].CGColor); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); CGFloat components[] = {0.0,0.0,1.0,1.0}; CGColorRef color = CGColorCreate(colorspace, components); CGContextSetStrokeColorWithColor(context, color); CGRect rectangle = CGRectMake(60, 20, 200,200); CGContextAddEllipseInRect(context, rectangle); CGContextStrokePath(context); /*CGRect rectangle1 = CGRectMake(130,170,50,10); CGContextAddRect(context,rectangle1); CGContextStrokePath(context);*/ /*CGContextMoveToPoint(context,100,200); CGContextAddArcToPoint(context,120,150,400,150,70 ); CGContextStrokePath(context);*/ /*CGContextMoveToPoint(context, 100,100); CGContextAddArcToPoint(context, -100,200, -400,200, 80); CGContextStrokePath(context);*/ CGContextSetStrokeColorWithColor(context,color); CGRect rectangle2 = CGRectMake(80, 90, 50, 8); CGContextAddEllipseInRect(context, rectangle2); CGContextStrokePath(context); CGContextSetStrokeColorWithColor(context,color); CGRect rectangle3 = CGRectMake(180, 90, 50, 8); CGContextAddEllipseInRect(context, rectangle3); CGContextStrokePath(context); CGContextSetStrokeColorWithColor(context,color); CGContextMoveToPoint(context, 155,120); CGContextAddLineToPoint(context, 155,160); CGContextStrokePath(context); /*CGContextSetStrokeColorWithColor(context, color); CGRect rectangle4 = CGRectMake(130, 180, 50,8); CGContextAddEllipseInRect(context, rectangle4); CGContextStrokePath(context);*/ /*CGContextSetStrokeColorWithColor(context,color); CGContextMoveToPoint(context, 120,180); CGContextAddLineToPoint(context, 190,180); CGContextStrokePath(context);*/ int value = (int)(slider.value); if(value == 25) { CGContextMoveToPoint(context, 120,180); CGContextAddArcToPoint(context, 190 , 180, 250 , 180, 0 ); CGContextStrokePath(context); } }

    Read the article

  • Decoration View *above* cells in UICollectionView

    - by Dhiraj Gupta
    I've got a decoration view showing the way I want, in my UICollectionView. The position and size is right. The decoration view stays at the frame I'm setting for it in my layout. But, I want the decoration view to be above the cells, not below them. I tried setting the zIndex property on the UICollectionViewLayoutAttributes for the decoration view, but this has no effect - I tried logging out the zindex of the cells, and they're all returning 0, and my decoration view's zIndex is set to 20. I'm guessing having decoration views above the cells is not supported, at least in UICollectionViewFlowLayout? Someone please confirm this, thanks! In the meantime, I'm going back to having a custom UIView subclass as a subview in the parent controller of the collection view and laying out the frame of it in the - (void) viewWillLayoutSubviews() method.

    Read the article

  • Calculate NSString size to adjust UITextField frame

    - by Bernd Plontsch
    I have issues calculating the accurate size of a NSString displayed in a UITextField. My goal is to update the textfield frame size according to the string size programmatically (without using sizeToFit). I am using the sizeWithFont function. -(void)resizeTextFieldAccordingToText:(NSString*)textFieldString { CGPoint originalCenter = self.textField.center; UIFont* currentFont = [textField font]; CGSize newSize = [textFieldString sizeWithFont:currentFont]; //Same incorrect results with the extended version of sizeWithFont, e.g. //[textFieldString sizeWithFont:currentFont constrainedToSize:CGSizeMake(300.0, 100.0) lineBreakMode:NSLineBreakByClipping]; [self.textField setFrame:(CGRectMake(self.textField.frame.origin.x, self.textField.frame.origin.y, newSize.width, newSize.height))]; [self.textField setCenter:originalCenter]; } Problem: While this return correct size results at first its becomes more and more unprecise by adding characters therefore finally starts clipping the string (as seen in the right screenshot). How do I get the accurate size of the textField string for correctly adjusting its size?

    Read the article

  • Speed up dialog/page transitions in jQuery Mobile on iPhone?

    - by Crashalot
    There are other SO questions on speeding up jQuery Mobile for Android, but does anyone know how to accelerate page transitions on iPhones, specifically dialog transitions? We're on JQM 1.0. JQM 1.1 is supposed to speed up page transitions (though we haven't seen any demos yet), but we're wondering if anyone has done anything for JQM 1.0. Right now, there is a two second delay, which is too much to show a dialog. We resort to one of two options. Using no animation for the page transition, which provides instant feedback, or rolling our own by binding to "touchstart" and animating the dialog, which is really just a big DIV inside the current page. Neither is ideal. Suggestions?

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >