Search Results

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

Page 9/19 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Converting a navbar to a tabbar app

    - by Nick
    Hey guys, I was wondering how to convert a NavigationController style app into a TabBarcontroller style app. I changed my mainwindow to not contain a navigationcontroller anymore (but a tabbarcontroller instead) and my delegate also appropiatly, but when I launch the app something still thinks I want a navigationController: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navigationController.' Stack trace: #0 0x020fa004 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ #1 0x96fc0509 in objc_exception_throw #2 0x020ee1c1 in -[NSException raise] #3 0x000d8a78 in _NSSetUsingKeyValueSetter #4 0x000d84c5 in -[NSObject(NSKeyValueCoding) setValue:forKey:] #5 0x004fb4c8 in -[UIRuntimeOutletConnection connect] #6 0x020af92f in -[NSArray makeObjectsPerformSelector:] #7 0x004f9f7f in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] #8 0x004fbfcb in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] #9 0x0033b0a6 in -[UIApplication _loadMainNibFile] #10 0x0034482a in -[UIApplication _runWithURL:sourceBundleID:] #11 0x00341b88 in -[UIApplication handleEvent:withNewEvent:] #12 0x0033d6d3 in -[UIApplication sendEvent:] #13 0x003440b5 in _UIApplicationHandleEvent #14 0x0265aed1 in PurpleEventCallback #15 0x02092b80 in CFRunLoopRunSpecific #16 0x02091c48 in CFRunLoopRunInMode #17 0x0033be69 in -[UIApplication _run] #18 0x00345003 in UIApplicationMain #19 0x00002ec8 in main at main.m:14 Where can I specify the app is a tabbarcontrolled app, instead of a navigationbarcontrolled app? Thanks in advance,

    Read the article

  • Migrating a simple application from Application Delegate to ViewController Class

    - by eco_bach
    Hi Frst of all wanted to send out a huge thanks for the great feedback and support. I have a simple application working, right now simply loads a sequence of images and alows the user to step thru the images by clicking a button. All of my logic is in my Application Delegate class, with the image loading, initialization of UIImage Views etc happening in my applicationDidFinishLaunching method. My next step is to migrate as much as possible all of the logic from this class to a ViewController, to take advantage of the extra functionality etc in viewcontrollers. All my images and imageViews are initialized like the following in my applicationDidFinishLaunching. img = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@image1.jpg" ofType:nil]]; imgView = [[UIImageView alloc] initWithImage:img]; How would I migrate this to a ViewController based application? Where would I put all of the logic currently in my applicationDidFinishLaunching method, or for loading of images, is it necessary to only load them here? Any feedback, tips, suggestions appreciated.

    Read the article

  • How do I use a UIView subclass as a container?

    - by dxq
    I'm trying to subclass UIView to create a custom view that is essentially a container. The subclass contains a UILabel and a UIImageView- I can't make either of them show up. Here's an example of what I've been trying: In my main view controller: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { ViewClass *myView = [[ViewClass alloc] initWithFrame:CGRectMake(100, 100, 150, 150)]; [view addSubview:myView]; } return self; } In my UIView subclass: - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { UILabel *word = [[[UILabel alloc] initWithFrame:[self bounds]] autorelease]; word.text = @"WHY ISN'T THIS SHOWING UP!?"; [self addSubview:word]; } return self; } Can anyone explain what I'm doing wrong? I'm way out of practice with UIKit and Obj-C, and I figure I'm probably missing something obvious.

    Read the article

  • Adding nil to NSMutableArray

    - by ayanonagon
    I am trying to create a NSMutableArray by reading in a .txt file and am having trouble setting the last element of the array to nil. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"namelist" ofType:@"txt"]; NSString *data = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; NSArray *list = [data componentsSeparatedByString:@"\n"]; NSMutableArray *mutableList = [[NSMutableArray alloc] initWithArray:list]; I wanted to use NSMutableArray's function addObject, but that will not allow me to add nil. I also tried: [mutableList addObject:[NSNull null]]; but that does not seem to work either. Is there a way around this problem?

    Read the article

  • size of an image

    - by Mike
    From times to times I have to know the width and height of images. I am using the following code: UIImage *imageU = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"myImage.png"]]; CGFloat imageW = CGImageGetWidth(imageU.CGImage); CGFloat imageH = CGImageGetHeight(imageU.CGImage); My question is that if it is there any other way to know the width and height of an image, in pixels, without having to load the image on a variable, that's probably consuming memory. Can the dimensions be read from the file directly without loading the whole image? thanks.

    Read the article

  • What should be proper location for sqlit3 database file?

    - by Elliot Chen
    Hi, Everyone: I'm using a sqlite3 database to store app's data. Instead of building a database within program, I introduced an existing db file: 'abc.sqlite' into my project and put it under my 'Resources' folder. So, I think this db file should be inside of 'bundle', so at my init function, I used following statement to read it out: NSString *path = [[NSBundle mainBundle] pathForResource:@"abc" ofType:"sqlite"]; if(sqlite3_open([path UTF8String], &database) != SQLITE_OK) ... It's ok that this db can be opened and data can be retrieved from it. BUT, someone told me that it's better to copy this db file into user folder: such as 'Document'. So, my question is: is it ok to use this db from main bundle directly or copy it to user folder then use that copy. Which is better? Thank you very much!

    Read the article

  • How do you create a writable copy of a sqlite database that is included in your iPhone Xcode project

    - by Iggy
    copy it over to your documents directory when the app starts. Assuming that your sqlite db is in your project, you can use the below code to copy your database to your documents directory. We are also assuming that your database is called mydb.sqlite. //copy the database to documents NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"mydb.sqlite"]; if(![fileManager fileExistsAtPath:path]) { NSData *data = [NSData dataWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/mydb.sqlite"]]; [data writeToFile:path atomically:YES]; } Anyone know of a better way to do this. This seems to work ...

    Read the article

  • Why does Custom UITableViewCell *sometimes* cause an NSInvalidArgumentException?

    - by Wayne Hartman
    I have created a custom UITableViewCell, but when I dequeue the cell, sometimes it throws an NSInvalidArgumentException: [UITableViewCell nameLabel]: unrecognized selector sent to instance 0x3b4e7f0 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UITableViewCell nameLabel]: unrecognized selector sent to instance 0x3b4e7f0' Now, my custom UITableViewCell does have an attribute nameLabel, so I am confused why it is throwing this error. Below is the code I use to dequeue the cell: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; CTMenuItemVO* key = [[[self retrieveCartItems] allKeys] objectAtIndex:row]; NSNumber* quantity = [[self retrieveCartItems] objectForKey:key]; static NSString* SectionsTableIdentifier = @"SectionsTableIdentifier2"; OrderItemCell* cell = (OrderItemCell*)[tableView dequeueReusableCellWithIdentifier: SectionsTableIdentifier]; if (cell == nil) { NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"OrderItemCell" owner:nil options:nil]; for(id currentObject in topLevelObjects) { if ([currentObject isKindOfClass:[UITableViewCell class]]) { cell = (OrderItemCell*) currentObject; break; } } } cell.nameLabel.text = key.Name; cell.qtyLabel.text = [quantity stringValue]; return cell; }

    Read the article

  • Cannot commit in sqlite using a wrapper

    - by user271753
    - (IBAction)SetupButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@"Money"ofType:@"sqlite"]; if (![sqlite open:writableDBPath]) return; [sqlite executeNonQuery:@"CREATE TABLE test (key TEXT NOT NULL, num INTEGER, value TEXT);"]; } Hey guys the above code runs at first but the next time , the table does not exists in the database ! I am using http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/ what am I doing wrong ? Or could you please suggest me a really simple tutorial for core data ?

    Read the article

  • Pushing View from UITableView Problem

    - by golfromeo
    Basically, what I want is to be able to press a record in a table, and have it push to another view. To do this, I created a nib file and a UIViewController subclass (for the "pushed" view). I set the nib file's "File Owner" to be the controller I created. Then, in the view controller of the table that will push that view, I set the didSelectRowIndexAtPath: method to include the following: SearchTableController *vc = [[SearchTableController alloc] initWithNibName:@"SearchTable" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:vc animated:YES]; [vc release]; (where "SearchTableController" is the name of the UIViewController subclass and "SearchTable" is the name of the nib file) However, when I run this code and click on the record, nothing happens- the app doesn't crash, but the view doesn't get pushed. The code is getting run, because it works when I NSLog(), but it doesn't seem to be pushing the view. Thanks for any help in advance.

    Read the article

  • iPhone SDK - Display more information about a selected CustomCell (custom UITableViewCell)

    - by Pittor
    If got a CustomCell loaded using: NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil options:nil]; I have no problems with the tableview but when I select a row I want display more information on that row(like facebook app)... using the typical "show more". At the beginning the row show "title" and "description". When I select that row i want to show "title", "description" and a webview... and, of course, make the row bigger to accommodate that objects. Maybe changing this CustomCell by another bigger CustomCell? I have no idea where to start. Thanks. Sorry for my english :S

    Read the article

  • Users adding views

    - by adamprocter
    I have created a main page (myAppViewController) and a add page rect button I have also created a page template (TemplateAViewController) all set up in Interface builder. I would like users to be able to add as many templates themselves and then page through them. I am not sure where to start. I can create views programmatic like so -(IBAction)createnewpage : (id) sender { myAppViewController *viewcontroller = [[myAppViewController alloc] initWithNibName:@"TemplateAViewController" bundle:[NSBundle mainBundle]]; [[self view] addSubview:viewcontroller.view]; } I then want to be able to navigate through these views- I guess I need to create a navigation controller to do this ?

    Read the article

  • Setting Corner Radius on UIImageView not working

    - by MarkPowell
    I'm at a bit of a loss. I've used the layer property of UIView to round the corners of multiple elements in my app. However, this one UIImageView is simply not complying. Not sure what I am missing. The UIImageView (called previewImage) is contained in a Table View Cell. I've tried setting the cornerRadius property multiple location (in the cell itself and in the controller that creates the cell) to no avail. static NSString *CellIdentifier = @"MyTableViewCell"; MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; cell.previewImage.layer.cornerRadius = 20; //Made it 20 to make sure it's obvious. } Is there something about the way cells are loaded that I'm missing?

    Read the article

  • Why my image is up side down?

    - by Tattat
    This is my drawInContext method: UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"png"]]; CGRect cropRect = CGRectMake(0, 0, 175, 175); CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], cropRect); CGRect imageRect; imageRect.origin = CGPointMake(0, 0); imageRect.size = CGSizeMake(175, 175); CGContextDrawImage(UIGraphicsGetCurrentContext(), imageRect, imageRef); CGImageRelease(imageRef); My image is upside down, how can I change it? What's wrong with my code? How can I change the image become normal?? thx .

    Read the article

  • Why Can't I import a UITableViewCell subclass ? That's weird....

    - by user320064
    It's like this, I created a UITableViewCell subclass called NewsItemCell, then I wanna use it in my FirstViewController.m, then I tried to import it, but the compiler keeps telling me this Below is my code, it is driving me mad, thank you if you can help. import "NewsItemCell.h" import "FirstViewController.h" @implementation FirstViewController @synthesize computers; (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"NewsItemCellIdentifier"; NewsItemcell *cell = (NewsItemcell *)[tableView dequeueReusableCellWithIdentifier: CellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NewsItemCell" owner:self options:nil]; for (id oneObject in nib) if ([oneObject isKindOfClass:[NewsItemcell class]]) cell = (NewsItemcell *)oneObject; } NSUInteger row = [indexPath row]; NSDictionary *rowData = [self.computers objectAtIndex:row]; cell.newsTitle.text = [rowData objectForKey:@"Color"]; cell.newsDate.text = [rowData objectForKey:@"Name"]; return cell; } Jason

    Read the article

  • MPMoviePlayerController stutter

    - by Paul
    Code : NSString *path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4v"]; MPMoviePlayerController *video = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; [video setBackgroundColor:[UIColor blackColor]]; video.scalingMode = MPMovieScalingModeAspectFill; [[ NSNotificationCenter defaultCenter ] addObserver: self selector: @selector(movieFinishedCallback:) name: MPMoviePlayerPlaybackDidFinishNotification object: aVideo ]; [video play]; ....movieFinishedCallback... [video release]; Result : Movie starts at frame 10 and then resets to frame 0, creating a stutter effect... Any Ideas ?

    Read the article

  • [NSData dataWithContentsOfFile:path] doesn't work

    - by Felics
    Hello, when I have the fallowing code to read a binary file: NSString* file = [NSString stringWithUTF8String:fileName]; NSString* filePath = resource ? [[NSBundle mainBundle] pathForResource:file ofType:nil] : [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent: file]; NSData* fileData = [NSData dataWithContentsOfFile:filePath]; Where "fileName" and resource are load function parameters. "resource" is used to know if the file is located in application bundle or in Documents. Sometimes this code works well and sometimes it doesn't. As far I saw this problem is random. I can run the code 10 times in a row and it works fine and after that it gives me nil data without any modification. Does anybody knows what could be the problem? Could it be related with file extension or file name? Thank you. PS: I use this code on iPhone Simulator and the file exists in application bundle.

    Read the article

  • Custom nib UITableViewCell height

    - by Chuck
    I've created a custom UITableViewCell in IB, linked it to the root view controller's property for it, and set it up in CellForRowAtIndexPath. But the height of my drawn cells doesn't match what I setup in IB, advice? Here's some screenshots and the code. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *AddressCellIdentifier = @"AddressCellIdent"; UITableViewCell *thisCell = [tableView dequeueReusableCellWithIdentifier:AddressCellIdentifier]; if (thisCell == nil) { [[NSBundle mainBundle] loadNibNamed:@"AddressCell" owner:self options:nil]; thisCell = addressCell; self.addressCell = nil; } return thisCell ; } addressCell is a @property (nonatomic, assign) IBOutlet UITableViewCell *addressCell;, and is linked up in IB to the file's owner (the table view controller). I'm using the example from Apple's table view programming guide.

    Read the article

  • image is not getting loaded in view.

    - by anurag
    I have created 2 views named "FirstView" and "SecondView".SecondView's nib file has an UIImage view object as its IBOtlet.Now I am getting an UIImage object from some FirstViewController's method.Now I am setting the SecondViewController's imageView property with that image and then I am pushing my SecondView Controller's object in Navigation Controller.The SecondView gets loaded but that image is not shown in that view. The code is as follows:..... - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; SecondViewController *secondView=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]]; secondView.imageView.image=img; [self.navigationController pushViewController:secondView animated:YES]; }

    Read the article

  • image is not getting loaded in view.

    - by anurag
    I have created 2 views named "FirstView" and "SecondView".SecondView's nib file has an UIImage view object as its IBOtlet.Now I am getting an UIImage object from some FirstViewController's method.Now I am setting the SecondViewController's imageView property with that image and then I am pushing my SecondView Controller's object in Navigation Controller.The SecondView gets loaded but that image is not shown in that view. The code is as follows:..... (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; SecondViewController *secondView=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]]; secondView.imageView.image=img; [self.navigationController pushViewController:secondView animated:YES]; }

    Read the article

  • Problems with UITableView when loading the view into the main window

    - by GuidoMB
    I've created a sub class of UITableViewController named LoginViewController with the XIB file using XCode. Then I opened the XIB file with IB and set the table's style to grouped. Finally I wrote the following code: - (void)applicationDidFinishLaunching:(UIApplication *)application { LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]]; [window addSubview: loginViewController.view]; window.backgroundColor = [UIColor blueColor]; [window makeKeyAndVisible]; [window layoutSubviews]; } I set the window's background color to blue for you to see what the problem is. I put a link to the screenshot If I don't use the table style grouped the problem does not occur

    Read the article

  • How to play audio file ios

    - by Camus
    I am trying to play an audio file but I can get it working. I imported the AVFoundation framework. Here is the code: NSString *fileName = [[NSBundle mainBundle] pathForResource:@"Alarm" ofType:@"caf"]; NSURL *url = [[NSURL alloc] initFileURLWithPath:fileName]; NSLog(@"Test: %@ ", url); AVAudioPlayer *audioFile = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL]; audioFile.delegate = self; audioFile.volume = 1; [audioFile play]; I am receiving an error nil string parameter I copied the file to the supporting files folder so the file is there. Can you guys help me? Thanks

    Read the article

  • UIWebview isn't displaying content I want it to display

    - by Knodel
    In my app I have a UIWebView which loads different rtf files. I use this function to load these files: - (void)loadFile:(NSString*)file { NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:file]; NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [webview loadRequest:request]; } The UIWebView displays nothing. When I enter the debugger, the file string value is which I need, but resourcePath and sourceFilePath values are "nil". What am I doing wrong? Thanks in advance!

    Read the article

  • Objective C: Why is this code leaking?

    - by Johnny Grass
    I'm trying to implement a method similar to what mytunescontroller uses to check if it has been added to the app's login items. This code compiles without warnings but if I run the leaks performance tool I get the following leaks: Leaked Object # Address Size Responsible Library Responsible Frame NSURL 7 < multiple > 448 LaunchServices LSSharedFileListItemGetFSRef NSCFString 6 < multiple > 432 LaunchServices LSSharedFileListItemGetFSRef Here is the responsible culprit: - (BOOL)isAppStartingOnLogin { LSSharedFileListRef loginListRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); if (loginListRef) { NSArray *loginItemsArray = (NSArray *)LSSharedFileListCopySnapshot(loginListRef, NULL); NSURL *itemURL; for (id itemRef in loginItemsArray) { if (LSSharedFileListItemResolve((LSSharedFileListItemRef)itemRef, 0, (CFURLRef *) &itemURL, NULL) == noErr) { if ([[itemURL path] hasPrefix:[[NSBundle mainBundle] bundlePath]]) { [loginItemsArray release]; CFRelease(loginListRef); return YES; } } } [loginItemsArray release]; CFRelease(loginListRef); } return NO; }

    Read the article

  • How to release audio properly? (AVAudioPlayer)

    - by Aluminum
    Hello everyone! I need help with my iOS application ^^,. I want to know if I'm releasing AVAudioPlayer correctly. MyViewController.h #import <UIKit/UIKit.h> @interface MyViewController : UIViewController { NSString *Path; } - (IBAction)Playsound; @end MyViewController.m #import <AVFoundation/AVAudioPlayer.h> #import "MyViewController.h" @implementation MyViewController AVAudioPlayer *Media; - (IBAction)Playsound { Path = [[NSBundle mainBundle] pathForResource:@"Sound" ofType:@"wav"]; Media = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:Path] error:NULL]; [Media play]; } - (void)dealloc { [Media release]; [super viewDidUnload]; } @end

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >