Search Results

Search found 560 results on 23 pages for 'nsdictionary'.

Page 18/23 | < Previous Page | 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Why does my iOS app crash when trying presentModalViewController?

    - by user555807
    I've been banging my head against this all day, it seems like something simple but I can't figure it out. I've got an iOS app that I created using the "View-based Application" template in XCode. Here is essentially the code I have: AppDelegate.h: #import <UIKit/UIKit.h> @interface AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MainViewController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet MainViewController *viewController; @end AppDelegate.m: #import "AppDelegate.h" #import "MainViewController.h" @implementation AppDelegate @synthesize window, viewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self.window addSubview:viewController.view]; [self.window makeKeyAndVisible]; return YES; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end MainViewController.h: #import <UIKit/UIKit.h> @interface MainViewController : UIViewController { } -(IBAction) button:(id)sender; @end MainViewController.m: #import "MainViewController.h" #import "ModalViewController.h" @implementation MainViewController ... -(IBAction) button:(id)sender { ModalViewController *mvc = [[[ModalViewController alloc] initWithNibName:NSStringFromClass([ModalViewController class]) bundle:nil] autorelease]; [self presentModalViewController:mvc animated:YES]; } @end There's nothing of interest in the ModalViewController. So the modal view should display when the button is pressed. When I press the button, it hangs for a second then crashes back to the home screen with no error message. I am stumped, please show me what I'm doing wrong!

    Read the article

  • Update a tableView with a plist took from another table

    - by Pheel
    Background: I have a tab bar application, which has a tableView as the "heart" of the app. It loads data from a plist and, through a button that checks if there are any updates on the remote plist file, updates the local plist with the remote contents. Then, i have another tableView, that should display only those plist items that have a bool value set to YES. Now i want to add a button to the second table that reloads the plist took from the first table. Expected: When i update the local plist from the first table and when i press the button on the second table, the 2nd table is supposed to update and show the cells with that bool value set to YES. (Note: I set YES as default to some items on plist). What happens: The first table updates its content from remote. The second table shows the old items with the value set to YES. When i press the button to refresh data, it reads the plist fine (by logging it, it has the same contents of the first table -only those set to YES-),but it doesn't update data even if i have [self.tableView reloadData];. When i close the app and open it again, the second table is filled with the right items. :\ Code i'm using: //Reading Plist { NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *plistPath = [[documentPaths lastObject] stringByAppendingPathComponent:@"myPlist.plist"]; NSFileManager *fMgr = [NSFileManager defaultManager]; if (![fMgr fileExistsAtPath:plistPath]) { plistPath = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"]; } NSMutableArray *returnArr = [NSMutableArray arrayWithContentsOfFile:plistPath]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"isFav == YES"]; for (NSDictionary *sect in returnArr) { NSArray *arr = [sect objectForKey:@"Rows"]; [sect setValue:[arr filteredArrayUsingPredicate:predicate] forKey:@"Rows"]; } [self.tableView reloadData]; } //Refresh data button - (void) refreshTable:(id)sender { NSLog(@"plist read"); [self readPlist]; NSLog(@"refreshed plist:%@",[self readPlist]); [self.tableView reloadData]; } Does anyone know why the table is not updating?

    Read the article

  • iOS MapKit: Selected MKAnnotation coordinates.

    - by Oh Danny Boy
    Using the code at the following tutorial, http://www.zenbrains.com/blog/en/2010/05/detectar-cuando-se-selecciona-una-anotacion-mkannotation-en-mapa-mkmapview/, I was able to add an observer to each MKAnnotation and receive a notification of selected/deselected states. I am attempting to add a UIView on top of the selection annotation to display relevant information about the location. This information cannot be conveyed in the 2 lines allowed (Title/Subtitle) for the pin's callout. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { Annotation *a = (Annotation *)object; // Alternatively attempted using: //Annotation *a = (Annotation *)[mapView.selectedAnnotations objectAtIndex:0]; NSString *action = (NSString *)context; if ([action isEqualToString:ANNOTATION_SELECTED_DESELECTED]) { BOOL annotationSelected = [[change valueForKey:@"new"] boolValue]; if (annotationSelected) { // Actions when annotation selected CGPoint origin = a.frame.origin; NSLog(@"origin (%f, %f) ", origin.x, origin.y); // Test UIView *v = [[UIView alloc] init]; [v setBackgroundColor:[UIColor orangeColor]]; [v setFrame:CGRectMake(origin.x, origin.y , 300, 300)]; [self.view addSubview:v]; [v release]; }else { // Accions when annotation deselected } } } Results using Annotation *a = (Annotation *)object origin (154373.000000, 197135.000000) origin (154394.000000, 197152.000000) origin (154445.000000, 197011.000000) Results using Annotation *a = (Annotation *)[mapView.selectedAnnotations objectAtIndex:0]; origin (0.000000, 0.000000) origin (0.000000, 0.000000) origin (0.000000, 0.000000) The numbers are large. They are not relative to the view (1024 x 768). I believe they are relative to the entire map. How would I be able to detect the exact coordinates relative to the entire view so that I can appropriately position my view?

    Read the article

  • MKAnnotations are being made successfully, however they sometimes fail to render on MKMapView

    - by jtkendall
    I'm working on an iPhone app using the 3.1.3 SDK, my app finds the users current location, displays it on a MKMapView and then finds nearby locations and renders them as MKAnnotations. My code is working, however sometimes the nearby annotations do not appear on the map. They are still being made as I see the correct data in the console (from NSLog which runs just after the annotations are made). When it fails is completely random, it could be the 5th time I've hit "Build and Run" for the day, or the 500th it doesn't appear to have any pattern and doesn't throw any type of error, it just doesn't add the annotations to the MapView. This is the method called for each nearby location to add the MKAnnotation. - (void)addPinsWithLocation:(NSDictionary *)spot { CLLocationCoordinate2D location; location.longitude = [[spot objectForKey:@"spot_longitude"] doubleValue]; location.latitude = [[spot objectForKey:@"spot_latitude"] doubleValue]; PlaceMarks *placemark = [[PlaceMarks alloc] initWithCoordinate:location title:[spot objectForKey:@"spot_name"] subtitle:@""]; NSLog(@"Adding Pin for Location: '%@' at %f, %f", [spot objectForKey:@"spot_name"], location.latitude, location.longitude); [mapView addAnnotation:placemark]; } Any ideas on how to get MKAnnotations to always show?

    Read the article

  • ObjectiveFlickr - how to call getSizes on a photo ID not known until the response?

    - by Jonathan Cohen
    Hi guys, I'm building a free music instrument iPhone app with the Flickr API and ObjectiveFlickr.A random photo from the interestingness list is displayed in the background, but I can't center it without knowing its size. (so I can reset the UIWebView frame) I've been researching this for awhile, and if the answer is super easy, please have some mercy on a noob - it's my first time playing with a web service API. =) Since I don't know the photo ID until after I receive the response from the interestingness feed, how would I call flickr.photo.getSizes on the response? This is what I have so far: - (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary{ int randomResponse = arc4random() % 49; photoDict = [[inResponseDictionary valueForKeyPath:@"photos.photo"] objectAtIndex:randomResponse]; NSString *photoID = [photoDict valueForKeyPath:@"id"]; NSLog(@"%@",photoID); NSURL *photoURL = [flickrContext photoSourceURLFromDictionary:photoDict size:OFFlickrMediumSize]; NSString *htmlSource = [NSString stringWithFormat: @"<html>" @"<head>" @" <style>body { margin: 0; padding: 0; } </style>" @"</head>" @"<body>" @"<img src=\"%@\" />" @"</body>" @"</html>" , photoURL]; [webView loadHTMLString:htmlSource baseURL:nil]; }

    Read the article

  • How to make UIImagePickerController works under switch case UIActionSheet

    - by Phy
    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *tempImage = [info objectForKey:UIImagePickerControllerOriginalImage]; imgview.image = tempImage; [self dismissModalViewControllerAnimated:YES]; [picker release]; } -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [self dismissModalViewControllerAnimated:YES]; [picker release]; } -(IBAction) calllib { img1 = [[UIImagePickerController alloc] init]; img1.delegate = self; img1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentModalViewController:img1 animated:YES]; } all the codes above works well for taking out photos from the photo library. problem is that when i tried to use it under the UIActionSheet it does not work. i just copy the lines of codes from the -(IBAction) calllib as follow. (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { UIImage *detectface = [Utilities detectFace:imgview.image]; UIImage *grayscale = [Utilities grayscaleImage:imgview.image]; UIImage *avatars = [Utilities avatars:imgview.image]; img1 = [[UIImagePickerController alloc] init]; img1.delegate = self; img1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; switch (buttonIndex) { case 0: [self presentModalViewController:img1 animated:YES]; imgview.image = detectface; break; case 1: [self presentModalViewController:img1 animated:YES]; imgview.image = grayscale; break; case 2: [self presentModalViewController:img1 animated:YES]; imgview.image = avatars; break; default: break; } } it does not work. can somebody help me to figure out what is the problem? the switch case works perfectly without the [self presentModalViewController:img1 animated:YES]; ... thanks

    Read the article

  • Common NSNotification mistakes?

    - by Ben Packard
    A simplification... A building has an array of apartment objects. Each apartment has a single currentTenant. These tenants are of type Person. Note that currentTenant doesn't have a reference to the apartment, so can't send information back up the chain. When a tenant has a plumbing issue he raises an NSNotification: [nc postNotificationName:@"PlumbingIssue" object:self]; Each Apartment observes notifications ONLY FROM it's own current tenant (this is set up when the apartment is built, before there is a current tenant): [nc addObserver:self selector:@selector(alertBuildingManager:) name:@"PlumbingIssue" object:[self currentTenant]; When the apartment receives a notification from it's own currentTenant, it sends it's own notification, "PlumberRequired", along with the apartment number and the currentTenant in an NSDictionary. Apartment observes these notifications, which it will take from any apartment (or other object): [nc addObserver:self selector:@selector(callPlumber) name:@"PlumberRequired" object:nil]; Is there something I could be getting fundamentally wrong here? What's happening is that the apartment is receiving notifications from any and all currentTenants, rather than jus it's own. Sorry that the actual code is a bit too unwieldy to post. Was just wondering if there's a gap in my understanding about observing notifications from a particular sender?

    Read the article

  • Apply a Quartz filter while saving PDF under Mac OS X 10.6.3

    - by olpa
    Using Mac OS X API, I'm trying to save a PDF file with a Quartz filter applied, just like it is possible from the "Save As" dialog in the Preview application. So far I've written the following code (using Python and pyObjC, but it isn't important for me): -- filter-pdf.py: begin from Foundation import * from Quartz import * import objc page_rect = CGRectMake (0, 0, 612, 792) fdict = NSDictionary.dictionaryWithContentsOfFile_("/System/Library/Filters/Blue \ Tone.qfilter") in_pdf = CGPDFDocumentCreateWithProvider(CGDataProviderCreateWithFilename ("test .pdf")) url = CFURLCreateWithFileSystemPath(None, "test_out.pdf", kCFURLPOSIXPathStyle, False) c = CGPDFContextCreateWithURL(url, page_rect, fdict) np = CGPDFDocumentGetNumberOfPages(in_pdf) for ip in range (1, np+1): page = CGPDFDocumentGetPage(in_pdf, ip) r = CGPDFPageGetBoxRect(page, kCGPDFMediaBox) CGContextBeginPage(c, r) CGContextDrawPDFPage(c, page) CGContextEndPage(c) -- filter-pdf.py: end Unfortunalte, the filter "Blue Tone" isn't applied, the output PDF looks exactly as the input PDF. Question: what I missed? How to apply a filter? Well, the documentation doesn't promise that such way of creating and using "fdict" should cause that the filter is applied. But I just rewritten (as far as I can) sample code /Developer/Examples/Quartz/Python/filter-pdf.py, which was distributed with older versions of Mac (meanwhile, this code doesn't work too): ----- filter-pdf-old.py: begin from CoreGraphics import * import sys, os, math, getopt, string def usage (): print ''' usage: python filter-pdf.py FILTER INPUT-PDF OUTPUT-PDF Apply a ColorSync Filter to a PDF document. ''' def main (): page_rect = CGRectMake (0, 0, 612, 792) try: opts,args = getopt.getopt (sys.argv[1:], '', []) except getopt.GetoptError: usage () sys.exit (1) if len (args) != 3: usage () sys.exit (1) filter = CGContextFilterCreateDictionary (args[0]) if not filter: print 'Unable to create context filter' sys.exit (1) pdf = CGPDFDocumentCreateWithProvider (CGDataProviderCreateWithFilename (args[1])) if not pdf: print 'Unable to open input file' sys.exit (1) c = CGPDFContextCreateWithFilename (args[2], page_rect, filter) if not c: print 'Unable to create output context' sys.exit (1) for p in range (1, pdf.getNumberOfPages () + 1): #r = pdf.getMediaBox (p) r = pdf.getPage(p).getBoxRect(p) c.beginPage (r) c.drawPDFDocument (r, pdf, p) c.endPage () c.finish () if __name__ == '__main__': main () ----- filter-pdf-old.py: end

    Read the article

  • selecting a row by means of a button ... using didSelectRowAtIndexPath

    - by John Smith
    hey people , I have a question concerning a button I would like to create which selects my previous selected row. This is what I came up so far but since I'm new with the functionality and such I could definately use some pointers I created a toolbar with a button and behind this button is the following action. -(void)clickRow { selectedRow = [self.tableView indexPathForSelectedRow]; [self.tableView:[self tableView] didSelectRowAtIndexPath:selectedRow]; } in my didSelectRowAtIndexPath there is a rootViewController being pushed rvController = [RootViewController alloc] ...etc So what I would like is my function clickRow to select the row and push the new rootviewcontroller (which has the right info since I'm using a tree ). I tried something like this as well -(void)clickRow { NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row]; NSArray *Children = [dictionary objectForKey:@"Children"]; rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]]; rvController.CurrentLevel += 1; rvController.CurrentTitle = [dictionary objectForKey:@"Title"]; [self.navigationController pushViewController:rvController animated:YES]; rvController.tableDataSource = Children; [rvController release]; } The last function works a little but a little is not enough;) For instance if I press the middle row or any other it constantly selects the toprow. thnx all for those of you reading and trying to help

    Read the article

  • How do I call an Obj-C method from Javascript?

    - by gnfti
    Hi all, I'm developing a native iPhone app using Phonegap, so everything is done in HTML and JS. I am using the Flurry SDK for analytics and want to use the [FlurryAPI logEvent:@"EVENT_NAME"]; method to track events. Is there a way to do this in Javascript? So when tracking a link I would imagine using something like <a onClick="flurryTrackEvent("Click_Rainbows")" href="#Rainbows">Rainbows</a> <a onClick="flurryTrackEvent("Click_Unicorns")" href="#Unicorns">Unicorns</a> "FlurryAPI.h" has the following: @interface FlurryAPI : NSObject { } + (void)startSession:(NSString *)apiKey; + (void)logEvent:(NSString *)eventName; + (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters; + (void)logError:(NSString *)errorID message:(NSString *)message exception:(NSException *)exception; + (void)setUserID:(NSString *)userID; + (void)setEventLoggingEnabled:(BOOL)value; + (void)setServerURL:(NSString *)url; + (void)setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose; @end I'm only interested in the logEvent method(s). If it's not clear by now, I'm comfortable with JS but a recovering Obj-C noob. I've read the Apple docs but the examples described there are all for newly declared methods and I imagine this could be simpler to implement because the Obj-C method(s) are already defined. Thank you in advance for any input.

    Read the article

  • How to parse the second child node from xml page in iphone

    - by Warrior
    I am new to iphone development.I want parse an you-tube XML page and retrieve its contents and display in a RSS feed. my xml page is <entry> <id>xxxxx</id> <title>xxx xxxx xxxx</title> <content>xxxxxxxxxxx</content> <media:group> <media:thumbnail url="http://tiger.jpg"/> </media:group> </entry> To retrieve the content i am using xml parsing. - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ currentElement = [elementName copy]; if ([elementName isEqualToString:@"entry"]) { entry = [[NSMutableDictionary alloc] init]; currentTitle = [[NSMutableString alloc] init]; currentcontent = [[NSMutableString alloc] init]; } } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ if ([elementName isEqualToString:@"entry"]) { [entry setObject:currentTitle forKey:@"title"]; [entry setObject:currentDate forKey:@"content"]; [stories addObject:[entry copy]]; }} - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ if ([currentElement isEqualToString:@"title"]) { [currentTitle appendString:string]; } else if ([currentElement isEqualToString:@"content"]) { [currentLink appendString:string]; } } I am able to retrieve id , title and content value and display it in a table-view.How can i retrieve tiger image URL and display it in table-view.Please help me out.Thanks.

    Read the article

  • UITableView: NSMutableArray not appearing in table

    - by Michael Orcutt
    I'm new to objective c and iPhone programming. I can't seem to figure out why no cells will fill when I run this code. The xml content displays in the console log and xcode displays no errors. Can any help? - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if(![elementName compare:@"Goal"] ) { tempElement = [[xmlGoal alloc] init]; } else if(![elementName compare:@"Title"]) { currentAttribute = [NSMutableString string]; } else if(![elementName compare:@"Progress"]) { currentAttribute = [NSMutableString string]; } } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if(![elementName compare:@"Goal"]) { [xmlElementObjects addObject:tempElement]; } else if(![elementName compare:@"Title"]) { NSLog(@"The Title of this event is %@", currentAttribute); [tempElement setTitled:currentAttribute]; } else if(![elementName compare:@"Progress"]) { NSLog(@"The Progress of this event is %@", currentAttribute); [tempElement setProgressed:currentAttribute]; } } - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(self.currentAttribute) { [self.currentAttribute appendString:string]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [xmlElementObjects count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [mtableview dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... cell.textLabel.text = [xmlElementObjects objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { }

    Read the article

  • How to check if something is stored in CoreData

    - by Terrel Gibson
    Hi I want to be able to tore some information in core data and but i am unsure of how to check if the file was saved properly. I tried using NSLog but it returns null when its called. I have a dictionary which has a uniqueID and a title which I want to save. I pass this in along with the context of the database. I then sort the database to check if it has any duplicates or not, if not then I add the file. +(VacationPhoto*) photoWithFlickrInfo: (NSDictionary*) flickrInfo inManagedObjectContext: (NSManagedObjectContext*) context{ //returns the dictionary NSLog(@"Photo To Store =%@", flickrInfo); VacationPhoto * photo = nil; NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"VacationPhoto"]; request.predicate = [NSPredicate predicateWithFormat:@"uniqueID = %@", [flickrInfo objectForKey:FLICKR_PHOTO_ID]]; NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES]; request.sortDescriptors = [NSArray arrayWithObject:descriptor]; NSError *error = nil; NSArray *matches = [context executeFetchRequest:request error:&error]; if (!matches || [matches count] > 1) { // handle error } else if ( [matches count] == 0){ photo.title = [flickrInfo objectForKey:FLICKR_PHOTO_TITLE]; //Returns NULL when called NSLog(@"title = %@", photo.title); photo.uniqueID = [flickrInfo objectForKey:FLICKR_PHOTO_ID]; //Returns NULL when called NSLog(@"ID = %@", photo.uniqueID); } else { //If photo already exists this is called photo = [matches lastObject]; } return photo; }

    Read the article

  • Can't process UIImage from UIImagePickerController and app crashes..

    - by eimaikala
    Hello guys, I am new to iPhone sdk and can't figure out why my application crashes. In the .h I have: UIImage *myimage; //so as it can be used as global -(IBAction) save; @property (nonatomic, retain) UIImage *myimage; In the .m I have: @synthesize myimage; - (void)viewDidLoad { self.imgPicker = [[UIImagePickerController alloc] init]; self.imgPicker.allowsImageEditing = YES; self.imgPicker.delegate = self; self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { myimage = [[info objectForKey:UIImagePickerControllerOriginalImage]retain]; [picker dismissModalViewControllerAnimated:YES]; } -(IBAction) process{ myimage=[self process:myimage var2:Val2 var3:Val3 var4:Val4]; UIImageWriteToSavedPhotosAlbum(myimage, nil, nil, nil); [myimage release]; } When the button process is clicked, the application crashes and really I have no idea why this happens. When i change it to: -(IBAction) process{ myimage =[UIImage imageNamed:@"im1.jpg"]; myimage=[self process:myimage var2:Val2 var3:Val3 var4:Val4]; UIImageWriteToSavedPhotosAlbum(myimage, nil, nil, nil); [myimage release]; } the process button works perfectly... Any help would be appreciated. Thanks in advance

    Read the article

  • Renderbuffer Width (Open GL ES)

    - by Josh Elsasser
    I'm currently experiencing an issue with an Open GL ES renderbuffer where the backing and width are are both set to 15. Is there any way to set them to the width of 320 and 480? My project is built up on Apple's EAGLView class and ES1Renderer, but I've moved it from the app delegate to a controller. I also moved the CADisplayLink outside of it (I update my game logic with the timestamp from this) Any help would be greatly appreciated. I add the glview to the window as follows: CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; [window addSubview:gameController.glview]; [window makeKeyAndVisible]; I synthesize the controller and the glview within it. The EAGLView and Renderer are otherwise unmodified. Renderer Initialization: // Get the layer CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = TRUE; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; renderer = [[ES1Renderer alloc] init]; Render "resize from layer" Method - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer { // Allocate color buffer backing based on the current layer size glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer]; glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); NSLog(@"Backing Width:%i and Height: %i", backingWidth, backingHeight); if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return NO; } return YES; }

    Read the article

  • Set Renderbuffer Width and Height (Open GL ES)

    - by Josh Elsasser
    I'm currently experiencing an issue with an Open GL ES renderbuffer where the backing and width are are both set to 15. Is there any way to set them to the width of 320 and 480? My project is built up on Apple's EAGLView class and ES1Renderer, but I've moved it from the app delegate to a controller. I also moved the CADisplayLink outside of it (I update my game logic with the timestamp from this) Any help would be greatly appreciated. I add the glview to the window as follows: CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; [window addSubview:gameController.glview]; [window makeKeyAndVisible]; I synthesize the controller and the glview within it. The EAGLView and Renderer are otherwise unmodified. Renderer Initialization: // Get the layer CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = TRUE; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; renderer = [[ES1Renderer alloc] init]; Render "resize from layer" Method - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer { // Allocate color buffer backing based on the current layer size glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer]; glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); NSLog(@"Backing Width:%i and Height: %i", backingWidth, backingHeight); if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return NO; } return YES; }

    Read the article

  • Can't add to NSMutableArray from SecondaryView

    - by Antonio
    Hi guys, I've searched and read and still haven't found a concrete answer. Brief: I have an application where I declare an NSMutableArray in my AppDelegate to synthesize when the application loads. (code below). I have a SecondaryViewController call this function, and I have it output a string to let me know what the array size is. Every time I run it, it executes but it does not add any objects to the array. How do I fix this? AppDelegate.h file #import <UIKit/UIKit.h> @class arrayTestViewController; @interface arrayTestAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; arrayTestViewController *viewController; NSMutableArray *myArray3; } @property (nonatomic, retain) NSMutableArray *myArray3; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet arrayTestViewController *viewController; -(void)addToArray3; @end AppDelegate.m file #import "arrayTestAppDelegate.h" #import "arrayTestViewController.h" @implementation arrayTestAppDelegate @synthesize window; @synthesize viewController; @synthesize myArray3; #pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { myArray3 = [[NSMutableArray alloc] init]; // Override point for customization after application launch. // Add the view controller's view to the window and display. [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } -(void)addToArray3{ NSLog(@"Array Count: %d", [myArray3 count]); [myArray3 addObject:@"Test"]; NSLog(@"Array triggered from SecondViewController"); NSLog(@"Array Count: %d", [myArray3 count]); } SecondViewController.m file #import "SecondViewController.h" #import "arrayTestAppDelegate.h" @implementation SecondViewController -(IBAction)addToArray{ arrayTestAppDelegate *object = [[arrayTestAppDelegate alloc] init]; [object addToArray3]; }

    Read the article

  • How does one make the camera on the iphone appear from the app delegate? Is it possible?

    - by K-RAN
    I'm just playing around with a simple program that opens the camera. That's literally all that I want to do. I'm a beginner and I believe that I have the basics down in terms of UI management for the iPhone so I decided to give this one a whirl. What I'm trying to do right now is... - (BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) launchOptions { UIImagePickerController * camera = [[UIImagePickerController alloc] init]; camera.delegate = self; camera.sourceType = UIImagePickerControllerSourceTypeCamera; camera.allowsEditing = NO; camera.showsCameraControls = NO; [viewController presentModalViewController:camera animated:NO]; [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES: } So basically, initialize the camera, set some things and show it in the main view. I set the camera's delegate to self because this code is placed in the delegate class (and yes, the delegate class is conforming to UIImagePickerControllerDelegate && UINavigationControllerDelegate). Main problem right now is that nothing is appearing on the screen. I have absolutely no idea what I'm doing wrong, especially since the program is building correctly with no errors or warnings... Any help is appreciated! Thanks a lot :D

    Read the article

  • Warning generated by UIButton setting code

    - by Spider-Paddy
    I have a for loop setting the background images on buttons, basically the buttons are thumbnail previews of different items & can't be set statically, however the code gives an warning because it runs through all the UIViews but then calls setBackgroundImage which does not apply to all views. The warning is an irritation, I understand what it's complaining about, how can I get rid of it? (I don't want to turn off the warning, I want to fix the problem) // For loop to set button images for (UIView *subview in [self.view subviews]) // Loop through all subviews { // Look for the tagged buttons, only the 8 tagged buttons & within array bounds if((subview.tag >= 1) && (subview.tag <= 8) && (subview.tag < totalBundles)) { // Retrieve item in array at position matching button tag (array is 0 indexed) NSDictionary *bundlesDataItem = [bundlesDataSource objectAtIndex:(subview.tag - 1)]; // Set button background to thumbnail of current bundle NSString *picAddress = [NSString stringWithFormat:@"http://some.thing.com/data/images/%@/%@", [bundlesDataItem objectForKey:@"Nr"], [bundlesDataItem objectForKey:@"Thumb"]]; NSURL *picURL = [NSURL URLWithString:picAddress]; NSData *picData = [NSData dataWithContentsOfURL:picURL]; // Warning is generated here [subview setBackgroundImage:[UIImage imageWithData:picData] forState:UIControlStateNormal]; } }

    Read the article

  • iPhone: Low memory crash...

    - by MacTouch
    Once again I'm hunting memory leaks and other crazy mistakes in my code. :) I have a cache with frequently used files (images, data records etc. with a TTL of about one week and a size limited cache (100MB)). There are sometimes more then 15000 files in a directory. On application exit the cache writes an control file with the current cache size along with other useful information. If the applications crashes for some reason (sh.. happens sometimes) I have in such case to calculate the size of all files on application start to make sure I know the cache size. My app crashes at this point because of low memory and I have no clue why. Memory leak detector does not show any leaks at all. I do not see any too. What's wrong with the code below? Is there any other fast way to calculate the total size of all files within a directory on iPhone? Maybe without to enumerate the whole contents of the directory? The code is executed on the main thread. NSUInteger result = 0; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSDirectoryEnumerator *dirEnum = [[[NSFileManager defaultManager] enumeratorAtPath:path] retain]; int i = 0; while ([dirEnum nextObject]) { NSDictionary *attributes = [dirEnum fileAttributes]; NSNumber* fileSize = [attributes objectForKey:NSFileSize]; result += [fileSize unsignedIntValue]; if (++i % 500 == 0) { // I tried lower values too [pool drain]; } } [dirEnum release]; dirEnum = nil; [pool release]; pool = nil; Thanks, MacTouch

    Read the article

  • Why doesn't the SplitView iPhone template have a nib file for the RootView?

    - by Dr Dork
    I'm diving into iPad development and am learning a lot quickly, but everywhere I look, I have questions. After creating a new SplitView app in Xcode using the template, it generates the AppDelegate class, RootViewController class, and DetailViewController class. Along with that, it creates a .xib files for MainWinow.xib and DetailView.xib. How do these five files work together? Why is there a nib file for the DetailView, but not the RootView? When I double click on the MainWindow.xib file, Interface Builder launches without a "View" window, why? Below is the code for didFinishLaunchingWithOptions method inside the AppDelegate class. Why are we adding the splitViewController as a subview? (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch rootViewController.managedObjectContext = self.managedObjectContext; // Add the split view controller's view to the window and display. [window addSubview:splitViewController.view]; [window makeKeyAndVisible]; return YES; } Thanks so much in advance for all your help! I still have a lot to learn, so I apologize if this question is absurd in any way. I'm going to continue researching these questions right now!

    Read the article

  • Custom Header in ASIHTTPREQUEST

    - by Sharon Nathaniel
    Here is my problem. I am using ASIHTTPREQUEST to send request and get response. Now my need of the time is to upload a image,audio , video or docs via PUT method with a custom header . The header takes filename , filesize,sha256sum,username,mediatype,resume as parameters. Here is the code how I am doing that . -(void)uploadFile { NSString *resume =@"0"; NSUserDefaults *userCredentials =[NSUserDefaults standardUserDefaults]; NSString *userName =[userCredentials objectForKey:@"userName"]; NSArray *objects =[NSArray arrayWithObjects:selectedMediaType,delegate.fileName,userName,fileSize,fileSHA256Sum,resume, nil]; NSArray *keys =[NSArray arrayWithObjects:@"mediatype",@"file_name",@"usrname",@"filesize",@"sha256sum",@"resume", nil]; discSentValue =[NSDictionary dictionaryWithObjects:objects forKeys:keys]; NSURL *url = [NSURL URLWithString:@"http://briareos.code20.com/putmedia.php"]; uploadMedia = [ASIFormDataRequest requestWithURL:url]; [uploadMedia addRequestHeader:@"MEDIA_UPLOAD_CUSTOM_HEADER" value:[discSentValue JSONRepresentation]]; [uploadMedia setData:dataToUpload forKey:@"File"]; [uploadMedia setDelegate:self]; [uploadMedia setRequestMethod:@"PUT"]; [uploadMedia startAsynchronous]; } But the server is unable to recognize the header , it always returns "invalid header"

    Read the article

  • how do i call mpmovieplayer from applicationwillresignactive in ppdelegate

    - by ss30
    i'm using mpmovieplayer to play audio stream, one problem i'm having trouble with handling intruptions e.g when call is received. My player is declared in viewcontroller and i beleive i need to do something in applicationdidresignactive in my appdelegate right? how do i do that if my appdelegate isn't aware of my moviePlayer? i'm new to iphone dev so i'm learning as i go and enjoying it :) here is what i'm doing in viewcontroller -(IBAction)play1MButton:(id)sender{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerStatus:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; NSString *url = @"http://22.22.22.22:8000/listen.pls"; [self.activityIndicator startAnimating]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]]; [moviePlayer prepareToPlay]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; } } -(void) moviePlayerStatus:(NSNotification*)notification { //MPMoviePlayerController *moviePlayer = notification.object; MPMoviePlaybackState playbackState = moviePlayer.playbackState; if(playbackState == MPMoviePlaybackStateStopped) { NSLog(@"MPMoviePlaybackStateStopped"); } else if(playbackState == MPMoviePlaybackStatePlaying) { NSLog(@"MPMoviePlaybackStatePlaying"); } else if(playbackState == MPMoviePlaybackStatePaused) { NSLog(@"MPMoviePlaybackStatePaused"); } else if(playbackState == MPMoviePlaybackStateInterrupted) { NSLog(@"MPMoviePlaybackStateInterrupted"); } else if(playbackState == MPMoviePlaybackStateSeekingForward) { NSLog(@"MPMoviePlaybackStateSeekingForward"); } else if(playbackState == MPMoviePlaybackStateSeekingBackward) { NSLog(@"MPMoviePlaybackStateSeekingBackward"); } } - (void) moviePlayerLoadStateChanged:(NSNotification*)notification { if ([moviePlayer loadState] != MPMovieLoadStateUnknown) { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer]; [moviePlayer play]; [self.activityIndicator stopAnimating]; [moviePlayer setFullscreen:NO animated:NO]; } } and in appdelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *setCategoryError = nil; [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]; if (setCategoryError) { } NSError *activationError = nil; [audioSession setActive:YES error:&activationError]; if (activationError) { } I can catch the errors but how do i use the player from appdelegate?!! thanks in advance

    Read the article

  • UINavigationController not working under ARC in iPhone

    - by user1811427
    I have creared a new project "Empty Application" template in Xcode 4.3, it is having only two classes AppDelegate.h & .m I cheaked with ARC to use automatic reference count while creating the app. I added two new files "RootViewController" & "NewProjectViewControllers". I implemented code to set navigation controller as follows in AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. rootViewController = [[MainViewController alloc] init]; UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:rootViewController]; [self.window addSubview:navigation.view]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } and in hte home view (Root view controller) implemented as follows - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Projects"; UINavigationBar *navigationBar = [self.navigationController navigationBar]; [navigationBar setTintColor: [UIColor colorWithRed:10/255.0f green:21/255.0f blue:51/255.0f alpha:1.0f]]; //To set the customised bar item UIButton *rightBarBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [rightBarBtn setBackgroundImage:[UIImage imageNamed:@"plus_new.png"] forState:UIControlStateNormal]; rightBarBtn.frame=CGRectMake(0.0, 100.0, 30.0, 30.0); [rightBarBtn addTarget:self action:@selector(addProject) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem* rightBarItem = [[UIBarButtonItem alloc] initWithCustomView:rightBarBtn]; self.navigationItem.rightBarButtonItem = rightBarItem; // Do any additional setup after loading the view from its nib. } - (void) addProject { NewProjViewController *editProject = [[NewProjViewController alloc] init]; [self.navigationController pushViewController:editProject animated:YES]; NSLog(@"xxxxxxxxxxxxxxx"); } But since i used ARC the navigation may dealoc immediately and it doesn't work, All the actions in method works except push to the next view if i do same thing with out ARC it works fine How to resolve this issue..? Thanks in advance

    Read the article

  • AFNetworking iOS

    - by Jeromiin
    I have a problem with a request in my app, I want to receive a json but because of the completion block my "PRINT 2" is print before my "PRINT 1" and of course my "PRINT 2" is null. I want the contrary and my "PRINT 2" to be filled but I can't manage to do it. -(void) makeConnection { NSURL *url = [NSURL URLWithString:[@"http://monsite.com/iPhonej/verifPseudo.php?login="stringByAppendingString:[_loginField.text stringByAppendingString:[@"&password=" stringByAppendingString:_passField.text]]]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFJSONResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { self.response = (NSDictionary *)responseObject; NSLog(@"PRINT 1 : %@", self.response[@"la"][@"reponse"][0][@"rep"]); [_dataLock lock]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Request Failed: %@, %@", error, error.userInfo); }]; [operation start]; } - (IBAction)logIn:(id)sender { [self makeConnection]; NSLog(@"PRINT 2 : %@", self.response[@"la"][@"reponse"][0][@"rep"]); } I know that AFNetworking is asynchronous but is there an other way to do the request and receive my json well ? Thank you

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23  | Next Page >