Search Results

Search found 451 results on 19 pages for 'nsbundle'.

Page 16/19 | < Previous Page | 12 13 14 15 16 17 18 19  | Next Page >

  • Activity Indicator not displaying based on whether the UIWebView is loading or not...

    - by Jack W-H
    Hi folks Sorry if this is an easy one. Basically, here is my code: MainViewController.h: // // MainViewController.h // Site // // Created by Jack Webb-Heller on 19/03/2010. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "FlipsideViewController.h" @interface MainViewController : UIViewController <UIWebViewDelegate, FlipsideViewControllerDelegate> { IBOutlet UIWebView *webView; IBOutlet UIActivityIndicatorView *spinner; } - (IBAction)showInfo; @property(nonatomic,retain) UIWebView *webView; @property(nonatomic,retain) UIActivityIndicatorView *spinner; @end MainViewController.m: // // MainViewController.m // Site // // Created by Jack Webb-Heller on 19/03/2010. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "MainViewController.h" #import "MainView.h" @implementation MainViewController @synthesize webView; @synthesize spinner; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { NSURL *siteURL; NSString *siteURLString; siteURLString=[[NSString alloc] initWithString:@"http://www.site.com"]; siteURL=[[NSURL alloc] initWithString:siteURLString]; [webView loadRequest:[NSURLRequest requestWithURL:siteURL]]; [siteURL release]; [siteURLString release]; [super viewDidLoad]; } - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller { [self dismissModalViewControllerAnimated:YES]; } - (void)webViewDidFinishLoad:(UIWebView *)webView { [spinner stopAnimating]; spinner.hidden=FALSE; NSLog(@"viewDidFinishLoad went through nicely"); } - (void)webViewDidStartLoad:(UIWebView *)webView { [spinner startAnimating]; spinner.hidden=FALSE; NSLog(@"viewDidStartLoad seems to be working"); } - (IBAction)showInfo { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil]; controller.delegate = self; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; [controller release]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [spinner release]; [webView release]; [super dealloc]; } @end Unfortunately nothing is ever written to my log, and for some reason the Activity Indicator never seems to appear. What's going wrong here? Thanks folks Jack

    Read the article

  • Integers not properly returned from a property list (plist) array in Objective-C

    - by Gaurav
    In summary, I am having a problem where I read what I expect to be an NSNumber from an NSArray contained in a property list and instead of getting a number such as '1', I get what looks to be a memory address (i.e. '61879840'). The numbers are clearly correct in the property list. Below is my process for creating the property list and reading it back. Creating the property list I have created a simple Objective-C property list with arrays of integers within one root array: <array> <array> <integer>1</integer> <integer>2</integer> </array> <array> <integer>1</integer> <integer>2</integer> <integer>5</integer> </array> ... more arrays with integers ... </array> The arrays are NSArray objects and the integers are NSNumber objects. The property list has been created and serialized using the following code: // factorArray is an NSArray that contains NSArrays of NSNumbers as described above // serialize and compress factorArray as a property list, Factors-bin.plist NSString *error; NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Factors-bin.plist"]; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:factorArray format:NSPropertyListBinaryFormat_v1_0 errorDescription:&error]; Inspecting the created plist, all values and types are correct. Reading the property list The property list is read in as Data and then converted to an NSArray: NSString *path = [[NSBundle mainBundle] pathForResource:@"Factors" ofType:@"plist"]; NSData *plistData = [[NSData alloc] initWithContentsOfFile:path]; NSPropertyListFormat format; NSString *error = nil; NSArray *factorData = (NSArray *)[NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; Cycling through factorData to see what it contains is where I see the erroneous integers: for (int i = 0; i < 10; i++) { NSArray *factorList = (NSArray *)[factorData objectAtIndex:i]; NSLog(@"Factors of %d\n", i + 1); for (int j = 0; j < [factorList count]; j++) { NSLog(@" %d\n", (NSNumber *)[factorList objectAtIndex:j]); } } I see all the correct number of values, but the values themselves are incorrect, i.e.: Factors of 3 61879840 (should be 1) 61961200 (should be 3) Factors of 4 61879840 (should be 1) 61943472 (should be 2) 61943632 (should be 4) Factors of 5 61879840 (should be 1) 61943616 (should be 5)

    Read the article

  • Can a View Controller manage more than 1 nib based view?

    - by Hugo Brynjar
    I have a VC controlling a screen of content that has 2 modes; a normal mode and an edit mode. Can I create a single VC with 2 views, each from separate nibs? In many situations on the iphone, you have a VC which controls an associated view. Then on a button press or other event, a new VC is loaded and its view becomes the top level view etc. But in this situation, I have 2 modes that I want to use the same VC for, because they are closely related. So I want a VC which can swap in/out 2 views. As per here: http://stackoverflow.com/questions/863321/iphone-how-to-load-a-view-using-a-nib-file-created-with-interface-builder/2683153#2683153 I have found that I can load a VC with an associated view from a nib and then later on load a different view from another nib and make that new view the active view. NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"EditMode" owner:self options:nil]; UIView *theEditView = [nibObjects objectAtIndex:0]; self.editView = theEditView; [self.view addSubview:theEditView]; The secondary nib has outlets wired up to the VC like the primary nib. When the new nib is loaded, the outlets are all connected up fine and everything works nicely. Unfortunately when this edit view is then removed, there doesn't seem to be any elegant way of getting the outlets hooked up again to the (normal mode) view from the original nib. Nib loading and outlet setting seems a once only thing. So, if you want to have a VC that swaps in/out 2 views without creating a new VC, what are the options? 1) You can do everything in code, but I want to use nibs because it makes creating the UI simpler. 2) You have 1 nib for your VC and just hide/show elements using the hidden property of UIView and its subclasses. 3) You load a new nib as described above. This is fine for the new nib, but how do you sort the outlets when you go back to the original nib. 4) Give up and accept having a 1:1 between VCs and nibs. There is a nib for normal mode, a nib for edit mode and each mode has a VC that subclasses a common superclass. In the end, I went with 4) and it works, but requires a fair amount of extra work, because I have a model class that I instantiate in normal mode and then have to pass to the edit mode VC because both modes need access to the model. I'm also using NSTimer and have to start and stop the timer in each mode. It is because of all this shared functionality that I wanted a single VC with 2 nibs in the first place.

    Read the article

  • Multiple View App shows Blank Screen in Simulator

    - by Brett Coburn
    Hello; I am developing a simple app that first shows a menu screen, and when a button is pressed, a game screen appears. I was able to develop the game screen without any issues, but when I changed the code to first display the menu, the simulator showed a blank screen. I've read all the articles on connecting views with IB but I can't figure this out. Any help would be appreciated. This is my code: // Pong_Multiple_ViewAppDelegate.h // Pong Multiple View // // Created by Brett on 10-05-19. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import <UIKit/UIKit.h> @class MenuViewController; @interface Pong_Multiple_ViewAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MenuViewController *navigationController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet MenuViewController *navigationController; @end // // Pong_Multiple_ViewAppDelegate.m // Pong Multiple View // // Created by Brett on 10-05-19. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "Pong_Multiple_ViewAppDelegate.h" #import "MenuViewController.h" @implementation Pong_Multiple_ViewAppDelegate @synthesize window; @synthesize navigationController; - (void)application:(UIApplication *)application{ // Override point for customization after application launch [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } - (void)dealloc { [navigationController release]; [window release]; [super dealloc]; } @end // // MenuViewController.h // Pong Multiple View // // Created by Brett on 10-05-19. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> #import "GameViewController.h" @interface MenuViewController : UIViewController { GameViewController *gameViewController; IBOutlet UIButton *gameButton; } @property(nonatomic, retain) GameViewController *gameViewController; @property(nonatomic, retain) UIButton *gameButton; -(IBAction)switchPage:(id)sender; @end // // MenuViewController.m // Pong Multiple View // // Created by Brett on 10-05-19. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "MenuViewController.h" #import "GameViewController.h" @implementation MenuViewController @synthesize gameViewController; @synthesize gameButton; -(IBAction)switchPage:(id)sender{ if (self.gameViewController==nil) { GameViewController *gameView = [[GameViewController alloc]initWithNibName:@"GameView" bundle:[NSBundle mainBundle]]; self.gameViewController= gameView; [gameView release]; } [self.navigationController pushViewController:self.gameViewController animated:YES]; } .... @end My code also includes classes: GameViewController.h, GameViewController.m, and nib files: MenuView.xib, and GameView.xib Thanks, B

    Read the article

  • Why does UIWebKit throw a structuralComplexityContribution exception?

    - by Axeva
    I've got a simple UIWebView in my iPhone app that's loading a XHTML document with some SGV embeded. This all works find on the desktop version of Safari, but it crashes in a UIWebView. Here is the Objective C: NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]; NSData *fileData = [NSData dataWithContentsOfFile: path]; [svgView loadData: fileData MIMEType: @"text/xml" textEncodingName: @"UTF-8" baseURL: [NSURL fileURLWithPath: path]]; I also tried a MIMEType of application/xhtml+xml, but it didn't help. Here is the HTML: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XTech SVG Demo</title> </head> <body> <svg xmlns="http://www.w3.org/2000/svg"> <g style="fill-opacity:0.7;"> <circle cx="6.5cm" cy="2cm" r="100" style="fill:red; stroke:black; stroke-width:0.1cm" transform="translate(0,50)" /> <circle cx="6.5cm" cy="2cm" r="100" style="fill:blue; stroke:black; stroke-width:0.1cm" transform="translate(70,150)" /> <circle cx="6.5cm" cy="2cm" r="100" style="fill:green; stroke:black; stroke-width:0.1cm" transform="translate(-70,150)"/> </g> </svg> </body> </html> All very basic stuff. When it loads on the iPhone, however, it crashes with this error: 2010-03-31 10:37:10.252 ColorDoodle[2014:20b] -[DOMElement structuralComplexityContribution]: unrecognized selector sent to instance 0x3e51b60 2010-03-31 10:37:10.253 ColorDoodle[2014:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[DOMElement structuralComplexityContribution]: unrecognized selector sent to instance 0x3e51b60' Any idea why? Is this a bug in the rendering engine of the UIWebView? I don't see anything too odd here. * Updated * There is definitely something screwy going on here. If I add this bit of code just inside the tag, it works fine: <form> </form> Take that code back out, and it crashes again.

    Read the article

  • UIIMageView, warning: check_safe_call: could not restore current frame

    - by lukya
    Hi, I am changing the image in UIImageView based on accelerometer input. The images are stored in an array. The application runs fine for a while and then crashes. warning: check_safe_call: could not restore current frame I am not using "UIImage ImageNamed" method when populating the array. The total size of all images is around 12 Mb. But individual images are very light (<100 kb) and i am using only one image at a time from the array. Just in case there are any autoreleases, I have allocated a NSAutoreleasePool in view did load and am draining it in the didReceiveMemoryWarning method (which does get called 2, 3 times before the app crashes?). Following is the code that creates images array: //create autorelease pool as we are creating many autoreleased objects NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *finalarr = [[NSMutableArray alloc] initWithCapacity:9]; NSLog(@"start loading"); for(int y = 0; y < 100; y+=10) { NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:10]; for(int x = 0; x < 10; x++) { NSString *imageName = [[NSString alloc] initWithFormat:@"0%d",y + x]; UIImage *img = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imageName ofType:@"png"]]; [arr addObject:img]; [imageName release]; [img release]; } [finalarr addObject:arr]; [arr release]; } NSLog(@"done loading"); // Override point for customization after app launch viewController.imagesArray = finalarr; [finalarr release]; //retain the array of images [viewController.imagesArray retain]; //release the aurtorelease pool to free memory taken up by objects enqued for release [pool release]; As the app runs smoothly for a while, which means array creation is definitely not the problem. After this the following method is called from [accelerometer didAccelerate] -(BOOL)setImageForX:(int)x andY:(int)y { [self.imageView setImage:(UIImage*)[(NSArray*)[self.imagesArray objectAtIndex:y] objectAtIndex:x]]; return TRUE; } So the only code being executed is the "UIImageView setImage". But no objects are being created here. Please let me know if the code seems to have any leaks or i am doing something wrong. Thanks, Swapnil

    Read the article

  • indentationLevelForRowAtIndexPath not indenting custom cell

    - by Xetius
    I have overridden the tableView:indentationLevelForRowAtIndexPath method in my UITableViewController derived class as follows: - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary* item = [self.projects objectAtIndex:indexPath.row]; int indentationLevel = [[item objectForKey:@"indent"] intValue]; DLog (@"Indentation Level for Row %d : %d", indexPath.row, indentationLevel); return indentationLevel; } I initially thought that this was not being called but that was operator error (err, mine) and I hadn't defined the symbol DEBUG=1. However, it is being called (duh me!) and this is the log output: -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 0 : 1 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 1 : 1 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 2 : 2 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 3 : 2 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 4 : 2 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 5 : 1 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 6 : 2 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 7 : 2 -[RootViewController tableView:indentationLevelForRowAtIndexPath:] [Line 129] Indentation Level for Row 8 : 1 But, this is not affecting the layout of the cells. No indentation. This is my itemCellForRowAtIndexPath implementation, if that makes any difference: -(UITableViewCell*)tableView:(UITableView *)tableView itemCellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellIdentifier = @"projectItemCell"; ProjectItemTableViewCell* cell = (ProjectItemTableViewCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"ProjectItemTableViewCell" owner:self options:nil]; for (id oneObject in nib) { if ([oneObject isKindOfClass:[ProjectItemTableViewCell class]]) { cell = (ProjectItemTableViewCell*)oneObject; } } } NSDictionary* item = [self.projects objectAtIndex:indexPath.row]; cell.projectDescLabel.text = [item objectForKey:@"name"]; cell.itemCountlabel.text = [NSString stringWithFormat:@"%d", [[item objectForKey:@"cache_count"] intValue]]; cell.itemCountlabel.backgroundColor = [UIColor colorForHex:[item objectForKey:@"color"]]; cell.indentationWidth = 20; return cell; } How do I indent a custom UITableViewCell which I have defined in Interface Builder? If I change the itemCellForRowAtIndexPath to use a default UITableViewCell with the code below, then it indents fine. static NSString* cellIdentifier = @"projectItemCell"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease]; } NSDictionary* item = [self.projects objectAtIndex:indexPath.row]; cell.textLabel.text = [item objectForKey:@"name"]; cell.indentationWidth = 40; return cell;

    Read the article

  • sqlite3_prepare_v2 throws SQLITE_ERROR in iPhone code

    - by incognitii
    I have a piece of code that used to work, and other iterations of it that DO work within the same app, and have compared code, and they are identical in structure. This is driving me INSANE!!!!!! In this instance, sqlite3_prepare_v2 is throwing one of those useless SQLITE_ERROR exceptions. Apparently, it can FIND the database, and OPEN the database, but it can't prepare a statement for it. Does ANYONE have any ideas? I'm desperate here. second_maindatabaseName = @"database.db"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; second_maindatabasePath = [documentsDir stringByAppendingPathComponent:second_maindatabaseName]; // Setup the database object sqlite3 *database; // Init the entry requirements Array BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; success = [fileManager fileExistsAtPath:second_maindatabasePath]; if(!success) { NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:second_maindatabaseName]; [fileManager copyItemAtPath:databasePathFromApp toPath:second_maindatabasePath error:nil]; [fileManager release]; } if(sqlite3_open([second_maindatabasePath UTF8String], &database) == SQLITE_OK) { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; value1 = [defaults stringForKey:kConst1]; value2 = [defaults stringForKey:kConst2]; value3 = [defaults stringForKey:kConst3]; value4 = [defaults stringForKey:kConst4]; const char *sqlStatement = "SELECT * FROM myTable WHERE Field1 = ? AND Field2 = ? AND Field3 = ? AND Field4 = ?"; sqlite3_stmt *compiledStatement; int error_code = sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL); if(error_code == SQLITE_OK) { // Loop through the results and add them to the feeds array sqlite3_bind_text(compiledStatement,1,[value1 UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement,2,[value2 UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement,3,[value3 UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement,4,[value4 UTF8String],-1,SQLITE_TRANSIENT); while(sqlite3_step(compiledStatement) == SQLITE_ROW) { // Read the data from the result row NSString *aNewValue = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)]; } } sqlite3_finalize(compiledStatement); } sqlite3_close(database);

    Read the article

  • iPhone dev: load a file from resource folder

    - by thomax
    I'm writing an iPhone app with a UIWebView which should display various html files I have in the app resource folder. In xcode my project overview, these html files are displayed like this: dirA |---> index.html |---> a1.html |---> a2.html |---> my.css |---> dirB |---> b1.html |---> b2.html |---> dirC |---> c1.html |---> c2.html These resources where added to the project as such: - Checked "Copy items into destination groups folder (if needed)". - Reference type: Default. - Text encoding: Unicode (utf-8). - Recursively create groups for any added folders. The links in my html are relative, meaning they look like this: <a href="a1.html">a2</a> <a href="a2.html">a2</a> <a href="dirB/b2.html">b2</a> <a href="dirC/c1.html">b2</a> In order to display the index.html when the app starts up, I use the following code: NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; This works fine. Following links from the index file also works fine, as long as the html files requested are directly under dirA. If the link followed points to a file in a sub-directory, then didFailLoadWithError will catch the situation and report that the requested file does not exist. Note that [webView loadHtmlString:myHtml]; cannot be part of the solution, as I need back and forward buttons to work in my web view. So the question is: How can I follow a relative link to an html file in a sub directory within my resources? I've been all over stackoverflow and the rest of the tubes for the past few days trying to figure this one out, but nowhere have I come across the solution to this exact problem. Any insight at all would be very, very much appreciated!

    Read the article

  • Setting UITableViewCell button image values during scrolling

    - by Rob
    I am having an issue where I am trying to save whether a repeat image will show selected or not (it is created as a UIButton on a UITableViewCell created in IB). The issue is that since the cell gets re-used randomly, the image gets reset or set somewhere else after you start scrolling. I've looked all over and the advice was to setup an NSMutableArray to store the button's selection state and I am doing that in an array called checkRepeatState My question is: where do I put the if-then-else statement in the code to where it will actually change the button image based on if the checkRepeatState is set to 0 or 1 for the given cell that is coming back into view? Right now, the if-then-else statement I am using has absolutely no effect on the button image when it comes into view. I'm very confused at this point. Thank you ahead of time for any insight you can give!!! My code is as follows: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // set up the cell static NSString *CellIdentifier = @"PlayerCell"; PlayerCell *cell = (PlayerCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) { [[NSBundle mainBundle] loadNibNamed:@"PlayerNibCells" owner:self options:nil]; cell = tmpCell; self.tmpCell = nil; NSLog(@"Creating a new cell"); } // Display dark and light background in alternate rows -- see tableView:willDisplayCell:forRowAtIndexPath:. cell.useDarkBackground = (indexPath.row % 2 == 0); // Configure the data for the cell. NSDictionary *dataItem = [soundCategories objectAtIndex:indexPath.row]; UILabel *label; label = (UILabel *)[cell viewWithTag:1]; label.text = [dataItem objectForKey:@"AnimalName"]; label = (UILabel *)[cell viewWithTag:2]; label.text = [dataItem objectForKey:@"Description"]; UIImageView *img; img = (UIImageView *)[cell viewWithTag:3]; img.image = [UIImage imageNamed:[dataItem objectForKey:@"Icon"]]; NSInteger row = indexPath.row; NSNumber *checkValue = [checkRepeatState objectAtIndex:row]; NSLog(@"checkValue is %d", [checkValue intValue]); // Reusing cell; make sure it has correct image based on checkRepeatState value UIButton *repeatbutton = (UIButton *)[cell viewWithTag:4]; if ([checkValue intValue] == 1) { NSLog(@"repeatbutton is selected"); [repeatbutton setImage:[UIImage imageNamed:@"repeatselected.png"] forState:UIControlStateSelected]; [repeatbutton setNeedsDisplay]; } else { NSLog(@"repeatbutton is NOT selected"); [repeatbutton setImage:[UIImage imageNamed:@"repeat.png"] forState:UIControlStateNormal]; [repeatbutton setNeedsDisplay]; } cell.accessoryType = UITableViewCellAccessoryNone; return cell; }

    Read the article

  • iphone cocos2d sprites disappearing

    - by jer
    I've been working on a game and implementing the physics stuff with chipmunk. All was going fine on the cocos2d part until the integration with chipmunk. A bit of background: The game is a game with blocks. Levels are defined in a property list, where positions, size of the blocks, gravitational forces, etc., are all defined for each block to be shown in the level. The problem is with the blocks showing up. I have a method on my BlockLayer class which is part of my game's main scene. Upon creation of the layer, the property list is read, and all the blocks are created. The following method is called to create the blocks: - (void)createBlock:(Block*)block withAssets:(NSBundle*)assets { Sprite* sprite; switch(block.blockColour) { case kBlockColourGreen: sprite = [Sprite spriteWithFile:[assets pathForResource:@"green" ofType:@"png" inDirectory:@"Blocks"]]; break; case kBlockColourOrange: sprite = [Sprite spriteWithFile:[assets pathForResource:@"orange" ofType:@"png" inDirectory:@"Blocks"]]; break; case kBlockColourRed: sprite = [Sprite spriteWithFile:[assets pathForResource:@"red" ofType:@"png" inDirectory:@"Blocks"]]; break; case kBlockColourBlue: sprite = [Sprite spriteWithFile:[assets pathForResource:@"blue" ofType:@"png" inDirectory:@"Blocks"]]; break; } sprite.position = block.bounds.origin; [self addChild:sprite]; if(block.blockColour == kBlockColourGreen || block.blockColour == kBlockColourRed) space-gravity = cpvmult(cpv(0, 10), 1000); cpVect verts[] = { cpv(-block.bounds.size.width, -block.bounds.size.height), cpv(-block.bounds.size.width, block.bounds.size.height), cpv(block.bounds.size.width, block.bounds.size.height), cpv(block.bounds.size.width, -block.bounds.size.height) }; cpBody* blockBody = cpBodyNew([block.mass floatValue], INFINITY); blockBody-p = cpv(block.bounds.origin.x, block.bounds.origin.y); blockBody-v = cpvzero; cpSpaceAddBody(space, blockBody); cpShape* blockShape = cpPolyShapeNew(blockBody, 4, verts, cpvzero); blockShape-e = 0.9f; blockShape-u = 0.9f; blockShape-data = sprite; cpSpaceAddShape(space, blockShape); } With the above code, the sprites never show up. However, if I comment out the "cpSpaceAddBody(space, blockBody);" line, the sprites show up. The position and size of the blocks are stored in the "bounds" property of instances of the Block class, which is a CGRect. Not sure if it's important, but the orientation of the app is in landscape left, and all the coordinates are based on that orientation. Any help would be greatly appreciated.

    Read the article

  • trouble to connect with AppStore in my InAppPurchase application(iPhone)

    - by riteshkumar1905
    There is problem to connect AppStore in my application. All things run fine in Simulator.But When i go with iPhone then AppStore is not connected.. I am also enclose the code which i call on button....... import "BuyController.h" import "InAppPurchaseManager.h" import "SKProducts.h" define kInAppPurchaseProUpgradeProductId @"com.vigyaapan.iWorkOut1" @implementation BuyController (IBAction)buy:(id)sender { /* get the product description (defined in early sections)*/ //[self requestProUpgradeProductData]; { if ([SKPaymentQueue canMakePayments]) { InAppPurchaseManager *Observer = [[InAppPurchaseManager alloc] init]; [[SKPaymentQueue defaultQueue] addTransactionObserver:Observer]; //NSURL *sandboxStoreURL = [[NSURL alloc]initWithString:@"http://sandbox.itunes.apple.com/verifyReceipt"]; //[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://sandbox.itunes.apple.com"]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/ com.vigyaapan.iWorkOut1?id=9820091347&;amp;amp;amp;amp;mt=8"]]; //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=301349397&;amp;amp;amp;amp;mt=8"]]; SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.vigyaapan.iWorkOut1"]; [[SKPaymentQueue defaultQueue] addPayment:payment]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"You are not authorized to purchase from AppStore" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; } //return [SKPaymentQueue canMakePayments]; } SKPayment *payment = [SKPayment paymentWithProductIdentifier:kInAppPurchaseProUpgradeProductId]; [[SKPaymentQueue defaultQueue] addPayment:payment]; //[self requestProUpgradeProductData]; /* get the product description (defined in early sections)*/ } /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle )nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; }/ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } (void)dealloc { [super dealloc]; } @end

    Read the article

  • Core Animation performance on iphone

    - by nico
    I'm trying to do some animations using Core Animation on the iphone. I'm using CABasicAnimation on CALayer. It's a straight forward animation from a random place at the top of the screen to the bottom of the screen at random speed, I have 30 elements that doing the same animation continuously until another action happens. But the performance on the iPhone 3G is very sluggish when the animations start. The image is only 8k. Is this the right approach? How should I change so it performs better. // image cached somewhere else. CGImageRef imageRef = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:@"png"]] CGImage]; - (void)animate:(NSTimer *)timer { int startX = round(radom() % 320); float speed = 1 / round(random() % 100 + 2); CALayer *layer = [CALayer layer]; layer.name = @"layer"; layer.contents = imageRef; // cached image layer.frame = CGRectMake(0, 0, CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); int width = layer.frame.size.width; int height = layer.frame.size.height; layer.frame = CGRectMake(startX, self.view.frame.origin.y, width, height); [effectLayer addSublayer:layer]; CGPoint start = CGPointMake(startX, 0); CGPoint end = CGPointMake(startX, self.view.frame.size.height); float repeatCount = 1e100; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; animation.delegate = self; animation.fromValue = [NSValue valueWithCGPoint:start]; animation.toValue = [NSValue valueWithCGPoint:end]; animation.duration = speed; animation.repeatCount = repeatCount; animation.autoreverses = NO; animation.removedOnCompletion = YES; animation.fillMode = kCAFillModeForwards; [layer addAnimation:animation forKey:@"position"]; } The animations are fired off using a NSTimer. animationTimer = [NSTimer timerWithTimeInterval:0.2 target:self selector:@selector(animate:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSDefaultRunLoopMode];

    Read the article

  • iphone Odd Problem when using a custom cell

    - by Brodie4598
    Please note where I have the NSLOG. All it is displaying in the log is the first three items in the nameSection. After some testing, I discovered it is displaying how many keys there are because if I add a key to the plist, it will log a fourth item in log. nameSection should be an array of the strings that make up the key array in the plist file. the plist file has 3 dictionaries, each with several arrays of strings. The code picks the dictionary I am working with correctly, then should use the array names as sections in the table and the strings en each array as what to display in each cell. so if the dictionary i am working with has 3 arrays, NSLOG will display 3 strings from the first array: 2010-05-01 17:03:26.957 Checklists[63926:207] string0 2010-05-01 17:03:26.960 Checklists[63926:207] string1 2010-05-01 17:03:26.962 Checklists[63926:207] string2 then stop with: 2010-05-01 17:03:26.963 Checklists[63926:207] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray objectAtIndex:]: index (3) beyond bounds (3)' if i added an array to the dictionary, it log 4 items instead of 3. I hope this explanation makes sense... -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [keys count]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { NSString *key = [keys objectAtIndex:section]; NSArray *nameSection = [names objectForKey:key]; return [nameSection count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger section = [indexPath section]; NSString *key = [keys objectAtIndex: section]; NSArray *nameSection = [names objectForKey:key]; static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier"; static NSString *ChecklistCellIdentifier = @"ChecklistCellIdentifier "; ChecklistCell *cell = (ChecklistCell *)[tableView dequeueReusableCellWithIdentifier: SectionsTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ChecklistCell" owner:self options:nil]; for (id oneObject in nib) if ([oneObject isKindOfClass:[ChecklistCell class]]) cell = (ChecklistCell *)oneObject; } NSUInteger row = [indexPath row]; NSDictionary *rowData = [self.keys objectAtIndex:row]; NSString *tempString = [[NSString alloc]initWithFormat:@"%@",[nameSection objectAtIndex:row]]; NSLog(@"%@",tempString); cell.colorLabel.text = [tempArray objectAtIndex:0]; cell.nameLabel.text = [tempArray objectAtIndex:1]; return cell; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; } [tableView deselectRowAtIndexPath:indexPath animated:NO]; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ NSString *key = [keys objectAtIndex:section]; return key; }

    Read the article

  • "Unable to find any mappings for the given content, keyPath=null" RestKit 0.2

    - by abisson
    So I switched to using RestKit 0.2 and CoreData and I've been having a lot of trouble trying to get the mappings correct... I don't understand why. The JSON Response of my server is like this: { "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 2 }, "objects": [{ "creation_date": "2012-10-15T20:16:47", "description": "", "id": 1, "last_modified": "2012-10-15T20:16:47", "order": 1, "other_names": "", "primary_name": "Mixing", "production_line": "/api/rest/productionlines/1/", "resource_uri": "/api/rest/cells/1/" }, { "creation_date": "2012-10-15T20:16:47", "description": "", "id": 2, "last_modified": "2012-10-15T20:16:47", "order": 2, "other_names": "", "primary_name": "Packaging", "production_line": "/api/rest/productionlines/1/", "resource_uri": "/api/rest/cells/2/" }] } Then in XCode I have: RKObjectManager *objectManager = [RKObjectManager sharedManager]; [AFNetworkActivityIndicatorManager sharedManager].enabled = YES; NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil]; RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel]; objectManager.managedObjectStore = managedObjectStore; RKEntityMapping *cellMapping = [RKEntityMapping mappingForEntityForName:@"Cell" inManagedObjectStore:managedObjectStore]; cellMapping.primaryKeyAttribute = @"identifier"; [cellMapping addAttributeMappingsFromDictionary:@{ @"id": @"identifier", @"primary_name": @"primaryName", }]; RKResponseDescriptor *responseCell = [RKResponseDescriptor responseDescriptorWithMapping:cellMapping pathPattern:@"/api/rest/cells/?format=json" keyPath:@"objects" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [objectManager addResponseDescriptorsFromArray:@[responseCell, responseUser, responseCompany]]; [managedObjectStore createPersistentStoreCoordinator]; NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"AppDB.sqlite"]; NSString *seedPath = [[NSBundle mainBundle] pathForResource:@"SeedDatabase" ofType:@"sqlite"]; NSError *error; NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:seedPath withConfiguration:nil options:nil error:&error]; NSAssert(persistentStore, @"Failed to add persistent store with error: %@", error); // Create the managed object contexts [managedObjectStore createManagedObjectContexts]; // Configure a managed object cache to ensure we do not create duplicate objects managedObjectStore.managedObjectCache = [[RKInMemoryManagedObjectCache alloc] initWithManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext]; My request is: [[RKObjectManager sharedManager] getObjectsAtPath:@"/api/rest/cells/?format=json" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { RKLogInfo(@"Load complete: Table should refresh..."); [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"LastUpdatedAt"]; [[NSUserDefaults standardUserDefaults] synchronize]; } failure:^(RKObjectRequestOperation *operation, NSError *error) { RKLogError(@"Load failed with error: %@", error); }]; And I always get the following error: **Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "Unable to find any mappings for the given content" UserInfo=0x1102d500 {DetailedErrors=(), NSLocalizedDescription=Unable to find any mappings for the given content, keyPath=null}** Thanks a lot!

    Read the article

  • Core-Data Can't pass managedObjectContext from app delegate to view controller

    - by yahuie
    I'm making a core-data application that is view based. I can create the managedObjectContext and 'use' it in the app delegate, but can not pass it to the mainviewcontroller. Probably something simple, but I can't find the problem after looking for quite a while. The managedObjectModel is nil in the mainviewcontroller. The log and error is here: 2010-06-02 11:01:10.504 TestCoreData[404:207] Could not make MOC in MainViewController implementation. 2010-06-02 11:01:10.505 TestCoreData[404:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Shelf'' 2010-06-02 11:01:10.506 TestCoreData[404:207] Stack: ( 30864475, 2452296969, 28852395, 12038, 3217218, 10258, 2700679, 2738614, 2726708, 2709119, 2736225, 38960473, 30649216, 30645320, 2702869, 2740143, 9704, 9558 ) (gdb) Code for app delegate here: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; self.mainViewController = aController; [aController release]; NSLog(@"before did finish launching"); if (self.managedObjectContext == nil) { NSLog(@"Could not make MOC in TestCoreDataAppDelegate implementation."); } //Just to see if I can access the here. NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Shelf" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; if (!entity) { NSLog(@"No Entity in TestCoreDataAppDelegate didfinishlaunching"); } NSLog(@"passed did finish launching"); NSManagedObjectContext *context = [self managedObjectContext]; self.mainViewController.view.frame = [UIScreen mainScreen].applicationFrame; self.mainViewController.managedObjectContext = context; [context release]; [window addSubview:[mainViewController view]]; [window makeKeyAndVisible]; return YES; } Code in MainViewController here: @implementation MainViewController @synthesize managedObjectContext; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { NSLog(@"Could not make MOC in MainViewController implementation."); } NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Shelf" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; } Thanks.

    Read the article

  • NSOperation inside NSOperationQueue not being executed

    - by Martin Garcia
    I really need help here. I'm desperate at this point. I have NSOperation that when added to the NSOperationQueue is not being triggered. I added some logging to see the NSOperation status and this is the result: Queue operations count = 1 Queue isSuspended = 0 Operation isCancelled? = 0 Operation isConcurrent? = 0 Operation isFinished? = 0 Operation isExecuted? = 0 Operation isReady? = 1 Operation dependencies? = 0 The code is very simple. Nothing special. LoadingConflictEvents_iPad *loadingEvents = [[LoadingConflictEvents_iPad alloc] initWithNibName:@"LoadingConflictEvents_iPad" bundle:[NSBundle mainBundle]]; loadingEvents.modalPresentationStyle = UIModalPresentationFormSheet; loadingEvents.conflictOpDelegate = self; [self presentModalViewController:loadingEvents animated:NO]; [loadingEvents release]; ConflictEventOperation *operation = [[ConflictEventOperation alloc] initWithParameters:wiLr.formNumber pWI_ID:wiLr.wi_id]; [queue addOperation:operation]; NSLog(@"Queue operations count = %d",[queue operationCount]); NSLog(@"Queue isSuspended = %d",[queue isSuspended]); NSLog(@"Operation isCancelled? = %d",[operation isCancelled]); NSLog(@"Operation isConcurrent? = %d",[operation isConcurrent]); NSLog(@"Operation isFinished? = %d",[operation isFinished]); NSLog(@"Operation isExecuted? = %d",[operation isExecuting]); NSLog(@"Operation isReady? = %d",[operation isReady]); NSLog(@"Operation dependencies? = %d",[[operation dependencies] count]); [operation release]; Now my operation do many things on the main method, but the problem is never being called. The main is never executed. The most weird thing (believe me, I'm not crazy .. yet). If I put a break point in any NSLog line or in the creation of the operation the main method will be called and everything will work perfectly. This have been working fine for a long time. I have been making some changes recently and apparently something screw things up. One of those changes was to upgrade the device to iOS 5.1 SDK (iPad). To add something, I have the iPhone (iOS 5.1) version of this application that use the same NSOperation object. The difference is in the UI only, and everything works fine. Any help will be really appreciated. Regards,

    Read the article

  • Converting OpenGL co-ordinates to lower UIView (and UIImagePickerController)

    - by John Qualis
    Hi, I am new to OpenGL over iPhone. I am developing an iPhone app similar to a barcode reader but with an extra OpenGL layer. The bottommost layer is UIImagePickerController, then I use UIView on top and draw a rectangle at certain co-ordinates on the iphone screen. So far everything is OK. Then I am trying to draw an OpenGL 3-D model in that rectangle. I am able to load a 3-D model in the iPhone based on this code here - http://iphonedevelopment.blogspot.com/2008/12/start-of-wavefront-obj-file-loader.html I am not able to transform the co-ordinates of the rectangle into OpenGL co-ordinates. Appreciate any help. Do I need to use a matrix to translate the currentPosition of the 3-D model so it is drawn within myRect? The code is given below.. Appreciate any help/pointers in this regards. John -(void)setupView:(GLView*)view { const GLfloat zNear = 0.01, zFar = 1000.0, fieldOfView = 45.0; GLfloat size; glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0); CGRect rect = view.bounds; glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar); glViewport(0, 0, rect.size.width, rect.size.height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); NSString *path = [[NSBundle mainBundle] pathForResource:@"plane" ofType:@"obj"]; OpenGLWaveFrontObject *theObject = [[OpenGLWaveFrontObject alloc] initWithPath:path]; Vertex3D position; position.z = -8.0; position.y = 3.0; position.x = 2.0; theObject.currentPosition = position; self.plane = theObject; [theObject release]; } (void)drawView:(GLView*)view; { static GLfloat rotation = 0.0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glColor4f(0.0, 0.5, 1.0, 1.0); // the coordinates of the rectangle are // myRect.x, myRect.y, myRect.width, myRect.height // Do I need to use a matrix to translate the currentPosition of the // 3-D model so it is drawn within myRect? //glOrthof(-160.0f, 160.0f, -240.0f, 240.0f, -1.0f, 1.0f); [plane drawSelf]; }

    Read the article

  • Updating DetailViewController from RootController

    - by Stefano Salmaso
    I'm trying to create an iPad application with a similar user interface to Apple's Mail application, i.e: RootView controller (table view) on the left hand side of the split view for navigation with a multiple view hierarchy. When a table cell is selected a new table view is pushed on the left hand side The new view on the left side can update the detail view. I can accomplish both tasks BUT NOT TOGETHER. I mean I can make a multi-level table view in the RootController.(HERE you can find the working source code). Or I can make a single-level table view in the RootController which can update the detailViewController (here there is the source code:http://www.megaupload.com/?d=D6L0463G). Can anyone tell me how to make a multi-level table in the RootController which can update a detailViewController? There is more source code at the link but below is the method in which I presume I have to declare a new detailViewController (which has to be put in the UISplitViewController): - (void)tableView:(UITableView *)TableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row]; //Get the children of the present item. NSArray *Children = [dictionary objectForKey:@"Children"]; // if([Children count] == 0) { /* Create and configure a new detail view controller appropriate for the selection. */ NSUInteger row = indexPath.row; UIViewController <SubstitutableDetailViewController> *detailViewController = nil; if (row == 0) { FirstDetailViewController *newDetailViewController = [[FirstDetailViewController alloc]initWithNibName:@"FirstDetailView" bundle:nil]; detailViewController = newDetailViewController; } if (row == 1) { SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc]initWithNibName:@"SecondDetailView" bundle:nil]; detailViewController = newDetailViewController; } // Update the split view controller's view controllers array. NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil]; splitViewController.viewControllers = viewControllers//nothing happens..... [viewControllers release];// } else { //Prepare to tableview. RootViewController *rvController = [[RootViewController alloc]initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]]; //Increment the Current View rvController.current_level += 1; //Set the title; rvController.current_title = [dictionary objectForKey:@"Title"]; //Push the new table view on the stack [self.navigationController pushViewController:rvController animated:YES]; rvController.tableDataSource = Children; [rvController.tableView reloadData]; //without this instrucion,items won't be loaded inside the second level of the table [rvController release]; } }

    Read the article

  • Problems with creating and using of delegate-protocols

    - by Flocked
    Hello, I have the problem that I have created a delegate protocol, but the necessary methods are not executed, although I have implemented the protocol in my header file. Here are the detailed explanation: I created an instance of my ViewController (TimeLineViewController), which will be displayed. This ViewController contains a UITableView, which in turn receives the individual Cells / Rows from one instance of my TableViewCell. So the ViewController creates an instance of TableCellView. The TableViewCell contains a UITextView, which contains web links. Now I want, that not safari opens the links, but my own built-in browser. Unfortunately TableViewCell can not open a new ViewController with a WebView, so I decided to create a delegate protocol. The whole thing looks like this: WebViewTableCellDelegate.h: @protocol WebViewTableCellDelegate -(void)loadWeb; @end Then I created a instance WebViewDelegate in the TableViewCell: id <WebViewTableCellDelegate> _delegate; In the .m of the TableViewCell: @interface UITextView (Override) @end @class WebView, WebFrame; @protocol WebPolicyDecisionListener; @implementation UITextView (Override) - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener { NSLog(@"request: %@", request); [_delegate loadWeb]; } @end - (void)setDelegate:(id <WebViewTableCellDelegate>)delegate{ _delegate = delegate;} And in my TimeLineViewController I implemented the protocol with < and the loadWeb-metode: - (void)loadWeb{ WebViewController *web = [[WebViewController alloc] initWithNibName:nil bundle:nil]; web.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController: web animated:YES]; [web release]; } And when the instance of the TableViewCell will be created in the TimelineViewController: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; MyIdentifier = @"tableCell"; TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if(cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil]; cell = tableCell;} [cell setDelegate:self]; //… } It is the first time I created a own delegate-protocol, so maybe there are stupid mistakes. Also I´m learnung Objective-C and programming generally only for 4 weeks. Thanks for your help! EDIT: I think i found the problem, but I dont know how to resolve it. I try to use [_delegate loadWeb]; in the subclass of the UITextView (because that is the only way i can react on the weblinks) and the subclass can´t use [_delegate loadWeb];. I tried this in a other methode and it worked.

    Read the article

  • SQLite/iPhone read copyright symbol

    - by Marco A
    Hi All, I am having problems reading the copyright symbol from a sqlite db that I have for my App that I am developing. I import the information manually, ie, from an excel sheet. I have tried two ways of doing it and failed with both: 1) Tried replacing the copyright symbol with "\u00ae" (unicode combination) within excel and then importing the modified file. - Result: I get the combination of \u00ae as a part of the string, it doesnt detect the unicode combination. 2) Tried leaving as it is. Importing the excel with the copyright symbol. - Result: I get a symbol that is different from the copyright, its something like an AE put together.looks like this: Æ Heres my code how I read from DB: -(void) readCategoriesFromDatabase:(NSString *) rest_input { // Init the products Array categories = [[NSMutableArray alloc] init]; // Open the database from the users filessytem rest_input = [rest_input stringByAppendingString:@"'"]; NSString *newString; newString = [@"select distinct category from food where restaurant='" stringByAppendingString:rest_input]; const char *cat_sqlStatement = [newString UTF8String]; sqlite3_stmt *cat_compiledStatement; if(sqlite3_prepare_v2(database, cat_sqlStatement, -1, &cat_compiledStatement, NULL) == SQLITE_OK) { // Loop through the results and add them to the feeds array while(sqlite3_step(cat_compiledStatement) == SQLITE_ROW) { NSString *catName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(cat_compiledStatement,0)]; // Create a new product object with the data from the database Product *category = [[Product alloc] initWithName:catName]; // Add the product object to the respective Array [categories addObject:category]; [category release]; } sqlite3_finalize(cat_compiledStatement); } NSLog(@"Finished Accessing Database to gather Categories...."); } I open the DB with this function: -(void) checkAndCreateDatabase{ NSLog(@"Checking/Creating Database...."); NSFileManager *fileManager = [NSFileManager defaultManager]; success = [fileManager fileExistsAtPath:databasePath]; [fileManager removeFileAtPath:databasePath handler:nil]; NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; [fileManager release]; if (sqlite3_open([databasePath UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); database = nil; } NSLog(@"Finished Checking/Creating Database...."); } Thanks to anything that can help me out.

    Read the article

  • how to set objectForKey to UISwitch to access switch for save selected option

    - by Rkm
    SystemUIViewcontroller has button event. Tap on Button fire InfoTableviewController. InfoTableview has UISwitch. How to set objectForKey to Info to access UIswitch ViewDidload of System... - (void)viewDidLoad { [super viewDidLoad]; self.Infoarray = [NSMutableArray array]; Info *info = [[Info alloc]initWithNibName:@"Info" bundle:nil]; [self.Infoarray addObject:[NSDictionary dictionaryWithObjectsAndKeys:info, @"viewController", nil]]; } SystemUIviewcontroller button event... -(IBAction) Info_Button_Clicked:(id) sender { Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:info animated:YES]; [info release]; } Here for Info TableviewController... - (void)viewDidLoad { [super viewDidLoad]; self.Soundarray = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @"Sounds", @"labelKey", self.SoundsswitchCtl, @"viewKey", nil],nil]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if ([indexPath section] == 0) { static NSString *kDisplayCell_ID = @"DisplayCellID"; cell = [self.tableView dequeueReusableCellWithIdentifier: kDisplayCell_ID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: kDisplayCell_ID] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } else { // the cell is being recycled, remove old embedded controls UIView *viewToRemove = nil; viewToRemove = [cell.contentView viewWithTag:1]; if (viewToRemove) [viewToRemove removeFromSuperview]; } cell.textLabel.text = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"labelKey"]; UIControl *control = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"viewKey"]; [cell.contentView addSubview:control]; return cell; } } - (UISwitch *)SoundsswitchCtl { if (SoundsswitchCtl == nil) { CGRect frame = CGRectMake(198.0, 12.0, 94.0, 27.0); SoundsswitchCtl = [[UISwitch alloc] initWithFrame:frame]; [SoundsswitchCtl addTarget:self action:@selector(switch_Sounds:) forControlEvents:UIControlEventValueChanged]; // in case the parent view draws with a custom color or gradient, use a transparent color SoundsswitchCtl.backgroundColor = [UIColor clearColor]; [SoundsswitchCtl setAccessibilityLabel:NSLocalizedString(@"StandardSwitch", @"")]; SoundsswitchCtl.tag = 1; // tag this view for later so we can remove it from recycled table cells } return SoundsswitchCtl; }

    Read the article

  • Error With Sending mail (kSKPSMTPPartMessageKey is nil)

    - by user1553381
    I'm trying to send mail in iPhone using "SKPSMTPMessage" and I added the libraries, In my class I added the following code: - (IBAction)sendMail:(id)sender { // if there are a connection if ([theConnection isEqualToString:@"true"]) { if ([fromEmail.text isEqualToString:@""] || [toEmail.text isEqualToString:@""]) { UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ??? ????? ???? ????????" delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [warning show]; }else { SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init]; test_smtp_message.fromEmail = fromEmail.text; test_smtp_message.toEmail = toEmail.text; test_smtp_message.relayHost = @"smtp.gmail.com"; test_smtp_message.requiresAuth = YES; test_smtp_message.login = @"[email protected]"; test_smtp_message.pass = @"myPass"; test_smtp_message.wantsSecure = YES; NSString *subject= @"Suggest a book for you"; test_smtp_message.subject = [NSString stringWithFormat:@"%@ < %@ > ",fromEmail.text, subject]; test_smtp_message.delegate = self; NSMutableArray *parts_to_send = [NSMutableArray array]; NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:plain_text_part]; // to send attachment NSString *image_path = [[NSBundle mainBundle] pathForResource:BookCover ofType:@"jpg"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @"inline;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey, @"base64",kSKPSMTPPartContentTransferEncodingKey, @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil]; [parts_to_send addObject:image_part]; test_smtp_message.parts = parts_to_send; Spinner.hidden = NO; [Spinner startAnimating]; ProgressBar.hidden = NO; HighestState = 0; [test_smtp_message send]; } }else { UIAlertView *alertNoconnection = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ???? ???? " delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [alertNoconnection show]; } } but when I tried to send it gives me the following Exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString appendString:]: nil argument' and it highlighted this line in SKPSMTPMessage.m [message appendString:[part objectForKey:kSKPSMTPPartMessageKey]]; and I Can't understand what is nil exactly Can Anyone help me in this issue? Thanks in Advance.

    Read the article

  • proper fill an image larger than screen

    - by madcat
    what I wanted to achieve here is simply fit the image width to the screen on both orientations and use UIScrollView to just allow scroll vertically to see the whole image. both viewController and view are created pragmatically. the image loaded is larger than screen on both width and height. here is the related code in my viewController: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)loadView { UIScreen *screen = [UIScreen mainScreen]; CGRect rect = [screen applicationFrame]; self.view = [[UIView alloc] initWithFrame:rect]; self.view.contentMode = UIViewContentModeScaleAspectFill; self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; UIImage *img=[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]]; UIImageView *imgView =[[UIImageView alloc] initWithImage:img]; [img release]; imgView.contentMode = UIViewContentModeScaleAspectFill; imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self.view addSubview:imgView]; [imgView release]; } tried all combinations for both contentMode above, did not give me correct result. the most close I am getting now: I manually resize imgView in loadView, portrait mode would display correctly since app always starts with portrait mode, but in landscape mode, the width fits correctly, but image is centered vertically rather than top aligned. if I add the imgView to a scrollView, in landscape mode it looks like contentSize is not set to full image size. but when I scroll bounce I can see the image is there in full size. question: why I need to resize it manually? in landscape mode how and where I can 'move' the imgView, so imgView.frame.origin is (0,0) and works correctly with a scroll view? Thanks! UPDATE: I added: imgView.clipsToBounds = YES; and find out in landscape mode the image bounds is smaller than screen in height. so the question becomes how to have the image view keeps original ratio (thus shows the full image always) when rotated to landscape? do I need to manually resize it after rotation again?

    Read the article

  • Why isnt my data persisting with nskeyedarchiver?

    - by aking63
    Im just working on what should be the "finishing touches" of my first iPhone game. For some reason, when I save with NSKeyedArchiver/Unarchiver, the data seems to load once and then gets lost or something. Here's what I've been able to deduce: When I save in this viewController, pop to the previous one, and then push back into this one, the data is saved and prints as I want it to. But when I save in this viewController, then push a new one and pop back into this one, the data is lost. Any idea why this might be happening? Do I have this set up all wrong? I copied it from a book months ago. Here's the methods I use to save and load. - (void) saveGameData { NSLog(@"LS:saveGameData"); // SAVE DATA IMMEDIATELY NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *gameStatePath = [documentsDirectory stringByAppendingPathComponent:@"gameState.dat"]; NSMutableData *gameSave= [NSMutableData data]; NSKeyedArchiver *encoder = [[NSKeyedArchiver alloc] initForWritingWithMutableData:gameSave]; [encoder encodeObject:categoryLockStateArray forKey:kCategoryLockStateArray]; [encoder encodeObject:self.levelsPlist forKey:@"levelsPlist"]; [encoder finishEncoding]; [gameSave writeToFile:gameStatePath atomically:YES]; NSLog(@"encoded catLockState:%@",categoryLockStateArray); } - (void) loadGameData { NSLog(@"loadGameData"); // If there is a saved file, perform the load NSMutableData *gameData = [NSData dataWithContentsOfFile:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"gameState.dat"]]; // LOAD GAME DATA if (gameData) { NSLog(@"-Loaded Game Data-"); NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:gameData]; self.levelsPlist = [unarchiver decodeObjectForKey:@"levelsPlist"]; categoryLockStateArray = [unarchiver decodeObjectForKey:kCategoryLockStateArray]; NSLog(@"decoded catLockState:%@",categoryLockStateArray); } // CREATE GAME DATA else { NSLog(@"-Created Game Data-"); self.levelsPlist = [[NSMutableDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kLevelsPlist ofType:@"plist"]]; } if (!categoryLockStateArray) { NSLog(@"-Created categoryLockStateArray-"); categoryLockStateArray = [[NSMutableArray alloc] initWithCapacity:[[self.levelsPlist allKeys] count]]; for (int i=0; i<[[self.levelsPlist allKeys] count]; i++) { [categoryLockStateArray insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; } } // set the properties of the categories self.categoryNames = [self.levelsPlist allKeys]; NUM_CATEGORIES = [self.categoryNames count]; thisCatCopy = [[NSMutableDictionary alloc] initWithDictionary:[[levelsPlist objectForKey:[self.categoryNames objectAtIndex:pageControl.currentPage]] mutableCopy]]; NUM_FINISHED = [[thisCatCopy objectForKey:kNumLevelsBeatenInCategory] intValue]; }

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19  | Next Page >