Search Results

Search found 51 results on 3 pages for 'nslocalizedstring'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Button color in Navigation bar - iPhone

    - by Mladen
    Hi guys, How to set this yellow button to be gray tinted one. I have tried adding image, but no luck Here is the screenshot: Here is my current code: (id)initWithStyle:(UITableViewStyle)style { if (self = [super initWithStyle:style]) { UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"") style:UIBarButtonItemStyleDone target:self action:@selector(GoToSettings)]; [addButton setImage:[[UIImage imageNamed:@"bg_table.png"] retain]]; self.navigationItem.rightBarButtonItem = addButton; self.navigationItem.hidesBackButton = TRUE; self.view.backgroundColor = [UIColor blackColor]; } return self; }

    Read the article

  • Show UIAlertView that is same as UIRemoteNotification when app is running in foreground

    - by Sidwyn Koh
    I understand that we can handle push notifications via the method: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo and we can check if the app was running in the foreground: if (application.applicationState == UIApplicationStateActive ) { ... } How do we show the exact same notification with localisation? NSString *message = [[[userInfo valueForKey:@"aps"] valueForKey:@"alert"] valueForKey:@"loc-key"]; NSString *trueMessage = NSLocalizedString(message, nil); UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:trueMessage cancelButtonItem:@"OK" otherButtonItems:@"Show", nil]; [alertView show]; This shows the raw unlocalized text, e.g. "You have a new alert from %1@ on %2@." My question is, how can we place the loc-args inside the UIAlertView as well, when the app is running in the foreground?

    Read the article

  • MPMediaickerController memory leak

    - by Joe
    This is code from Apple's Addmusic example. MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic]; picker.delegate = self; picker.allowsPickingMultipleItems = YES; picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item picker"); // The media item picker uses the default UI style, so it needs a default-style // status bar to match it visually [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES]; [self presentModalViewController: picker animated: YES]; [picker release]; I'm using this code in my app and the Leaks instrument highlights a leak on the line: [self presentModalViewController: picker animated: YES]; I think that this is because this line retains a reference to picker which cannot be subsequently released. Is there any way around this?

    Read the article

  • How simplify iPhone localization?

    - by mamcx
    I need to localiza a in development app for English & Spanish. Despite the fact I follow the Apple way of use NSLocalizedString & create nibs for both, I already lost the track of the new string that need to get localized and found with surprise that I need to redo the nibs in spanish when I change the master. (Just like this http://www.gigliwood.com/weblog/Cocoa/A_Great_Need_for_Be.html) I wonder if exist a better/alternative/more automated way. I know the use of gettext & poedit and wonder if something like that can be used. Or if exist some script or tool for this.

    Read the article

  • Why the macros in Objective-C / Cocoa?

    - by Joe
    I'm coming from a place without macros (Java/Python/C#/Scala) so perhaps my perspective is distorted but... Why are macros used in Cocoa? Two that spring to mind are NSLocalizedString and NSAssert (and STAssert). Would it be so hard / unsuitable to make them functions (which could be inlined)? I suppose I find them a little bizarre as an unnecessary throw-back to C (and yes, I am familiar with the pedigree of Obj-C). Is it just something that was done back in the day or is there a specific reason?

    Read the article

  • Background image for navigation view (iPhone)

    - by Mladen
    Hi Guys, I am having problems with properly displaying background image of navigation view. Here is the pic: Here is the code: (id)initWithStyle:(UITableViewStyle)style { if (self = [super initWithStyle:style]) { UIImage *image = [UIImage imageNamed: @"bg_table_active.png"]; UIImageView *imageview = [[UIImageView alloc] initWithImage: image]; UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"") style:UIBarButtonItemStyleDone target:self action:@selector(GoToSettings)]; self.navigationItem.titleView = imageview; self.navigationItem.rightBarButtonItem = addButton; self.navigationItem.hidesBackButton = TRUE; } return self; } How to make the picture stretch to whole navigation view?

    Read the article

  • How to create a formatted localized string?

    - by mystify
    I have a localized string which needs to take a few variables. However, in localization it is important that the order of the variables can change from language to language. So this is not a good idea: NSString *text = NSLocalizedString(@"My birthday is at %@ %@ in %@", nil); In some languages some words come before others, while in others it's reverse. I lack of an good example at the moment. How would I provide NAMED variables in a formatted string? Is there any way to do it without some heavy self-made string replacements? Even some numbered variables like {%@1}, {%@2}, and so on would be sufficient... is there a solution?

    Read the article

  • MPMediaickerController memory leak identified by Leaks instrument

    - by Joe
    This is code from Apple's Addmusic example. MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic]; picker.delegate = self; picker.allowsPickingMultipleItems = YES; picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item picker"); // The media item picker uses the default UI style, so it needs a default-style // status bar to match it visually [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES]; [self presentModalViewController: picker animated: YES]; [picker release]; I'm using this code in my app and the Leaks instrument highlights a leak on the line: [self presentModalViewController: picker animated: YES]; I think that this is because this line retains a reference to picker which cannot be subsequently released. Is there any way around this or is Leaks incorrectly identifying a leak?

    Read the article

  • Using the system localizations on iPhone

    - by nevan
    I want to make a back button for a navigation controller with the title "Back" instead of the title of the previous controller. I'm using this code: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", @"Back") style:UIBarButtonItemStyleBordered target:nil action:nil]; self.navigationItem.backBarButtonItem = backButton; I'd like to be able to skip localizing the "Back" string in my app (since I can only localize it in a limited number of languages). If I give my navigation controller no title, the back button will be automatically localized into whatever the language the user has chosen, so the system has translations of "Back" in many languages. Is there a way to access the localizations that are already present in the system and use them myself? These are things like "Back", "Cancel", "Done" and so on, which show up when creating one of the standard system buttons.

    Read the article

  • UITabBarController Modify [More ...] Appearance

    - by Mark
    Hello everyone, I would like to know if there is a way to change the text in the [More ...] tab. With the code below I am able to change the text in the view, however the text in the tab remains the same. Is there a way to access it and change it's appearance. tabBarController.moreNavigationController.topViewController.navigationItem.title = NSLocalizedString(@"Meer", ""); My second question is about the [Edit] button in the More view. The code below does not work. tabBarController.moreNavigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Wijzigen" style:UIBarButtonItemStyleDone target:nil action:nil]; Does anyone have an idea? Cheers.

    Read the article

  • Localizing a plist with grouped data

    - by Robert Altman
    Is there a way to localize a plist that contain hierarchical or grouped data? For instance, if the plist contains: Book 1 (dictionary) Key (string) Name (string) Description (localizable string) Book 2 (dictionary) Key (string) Name (string) Description (localizable string) (etcetera...) For the sake of the example, the Key and Name should not be translated (and preferably should not be duplicated in multiple localized property lists). Is there a mechanism for providing localizations for the localizable Description field without localizing the entire property list? The only other strategy that came to my mind is to store a lookup key in the description field and than use that to retrieve the localized text via NSLocalizedString(...) Thanks.

    Read the article

  • iPhone app -- are plists the way to handle default values and other languages?

    - by d_CFO
    I wrote my first program almost fifty years ago (yes, coding is still a blast, managing big projects with many programmers was not), but my Von Neumann thinking gets in the way. I want to (a) load default values and (b) account for multiple languages more elegantly (?) than 60-plus iterations of NSLocalizedString. Can I park all of this data into what amounts to a record with fields like this: (key value stuff), (tweak-able user prompt / screen name / whatever), (tasteful default), (user-supplied value)? NSUserDefault has worked well so far; Core Data looks like overkill (?), and sql lite, well, where's Oracle when you need it?

    Read the article

  • How to create an formatted localized string?

    - by mystify
    I have an localized string which needs to take a few variables. However, in localization it is important that the order of the variables can change from language to language. So this is not a good idea: NSString *text = NSLocalizedString(@"My birthday is at %@ %@ in %@", nil); In some languages some words come before others, while in others it's reverse. I lack of an good example for the moment. How would I provide NAMED variables in an formatted string? Is there any way to do it without some heavy self-made string replacements? Even some numbered variables like {%@1}, {%@2}, and so on would be sufficient... is there a solution?

    Read the article

  • Strange problem in Action sheet when click the Cancel Button in iphone

    - by Pugal Devan
    Hi, I have used action sheet in my view. Now i have faced one strange problem. If i clicked the cancel button, it dismissal the action sheet. But i clicked the cancel button, it works only Half part of the button(upper side only). Other part i clicked it doesnt work. (Half portion of the button only works. Eg: actionsheet size 320X40. clicking works only 320X20. Other part doesnt work). I have already used action sheet in many applcations. But i donno what i m doing wrong?. Please find me the problem where it is? See my code is, I have declared also UIActionsheetDelegate in interface class. - (void)viewDidLoad { UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Share", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(popupActionSheet)] autorelease]; self.navigationItem.rightBarButtonItem = addButton; } -(void)popupActionSheet { UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Share Post" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Email",@"Facebook",@"Twitter",nil]; popupQuery.actionSheetStyle = UIActionSheetStyleDefault; [popupQuery showInView:self.view]; [popupQuery release]; } Please help me out. Thanks.

    Read the article

  • UICollectionViewCell imageView

    - by Flink
    Code works fine until I changed UIViewController with tableView to UICollectionViewController. Now all cells shows same image, sometimes it flipping to nil. However textLabels are OK. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TourGridCell"; TourGridCell *cell = (TourGridCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; Guide *guideRecord = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.titleLabel.text = [guideRecord.name uppercaseString]; cell.titleLabel.backgroundColor = [UIColor clearColor]; if ([guideRecord.sights count] > 0) { if ([[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"]) { cell.imageView.image = [UIImage drawImage:[[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"] inImage:[UIImage imageNamed:@"MultiplePhotos"] inRect:CGRectMake(11, 11, 63, 63)]; }else { cell.imageView.image = [UIImage imageNamed:@"placeholder2"]; } NSMutableString *sightsSummary = [NSMutableString stringWithCapacity:[guideRecord.sights count]]; for (Sight *sight in guideRecord.sights) { if ([sight.name length]) { if ([sightsSummary length]) { [sightsSummary appendString:@", "]; } [sightsSummary appendString:sight.name]; } } if ([sightsSummary length]) { [sightsSummary appendString:@"."]; } cell.sightsTextLabel.text = sightsSummary; cell.detailTextLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i", nil) , [guideRecord.sights count]]; cell.detailTextLabel.hidden = NO; // cell.textLabel.alpha = 0.7; NSPredicate *enabledSightPredicate = [NSPredicate predicateWithFormat:@"notify == YES"]; NSArray *sightsEnabled = [[[guideRecord.sights array] filteredArrayUsingPredicate:enabledSightPredicate]mutableCopy]; NSPredicate *visitedSightPredicate = [NSPredicate predicateWithFormat:@"visited == YES"]; NSArray *sightsVisited = [[[guideRecord.sights array] filteredArrayUsingPredicate:visitedSightPredicate]mutableCopy]; if ([sightsEnabled count] > 0) { NSLog(@"green_badge"); cell.notifyIV.image = [UIImage imageNamed:@"green_badge"]; } else if (sightsVisited.count == 0) { NSLog(@"new_badge"); cell.notifyIV.image = [UIImage imageNamed:@"new_badge"]; } else { cell.notifyIV.image = nil; } } else { cell.notifyIV.hidden = YES; // cell.textLabel.textColor = RGB(0, 50, 140); cell.detailTextLabel.hidden = YES; cell.sightsTextLabel.text = nil; } return cell; }

    Read the article

  • Adjust size of MPMediaPickerController's view ?

    - by Mr.Gando
    In my application I don't use the upper bar that displays Wi-Fi/Date/Time because it's a game. However I need to be able to let my user to pick his music, so I'm using a MPMediaPickerController. The problem is, that when I present my controller, the controller ends up leaving a 10 pixels ( aprox ) bar at the top of the screen, just in the place the Wi-Fi/Date/Time bar, should be present. Is there a way I could make my MPMediaPickerController bigger ? or to be presented upper in the screen ? // Configures and displays the media item picker. - (void) showMediaPicker: (id) sender { MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAnyAudio]; [[picker view] setFrame:CGRectMake(0, 0, 320, 480)]; picker.delegate = self; picker.allowsPickingMultipleItems = YES; picker.prompt = NSLocalizedString (@"AddSongsPrompt", @"Prompt to user to choose some songs to play"); [self presentModalViewController:picker animated: YES]; [picker release]; } There I tried to set the size to 320x480 but no luck, the picker is still presented and leaves a space in the upper part of the screen, could anyone help me ? Btw, here's how it looks: I have asked a bit, and people told me this could indeed be a bug, what do you guys think ?

    Read the article

  • iPhone Localization: simple project not working

    - by gonso
    Hello Im doing my first localized project and I've been fighting with it for several hours with no luck. I have to create an app that, based on the user selection, shows texts and images in different languages. I've read most of Apple's documents on the matter but I cant make a simple example work. This are my steps so far: 1) Create a new project. 2) Manually create a "en.lproj" directory in the projects folder. 3) Using TexEdit create file called "Localizable.strings" and store it in Unicode UTF-16. The file looks like this: /* Localizable.strings Multilanguage02 Created by Gonzalo Floria on 5/6/10. Copyright 2010 __MyCompanyName__. All rights reserved. */ "Hello" = "Hi"; "Goodbye" = "Bye"; 4) I drag this file to the Resources Folder on XCode and it appear with the "subdir" "en" underneath it (with the dropdown triangle to the left). If I try to see it on XCode it looks all wrong, whit lots of ? symbols, but Im guessing thats because its a UTF-16 file. Right? 5) Now on my view did load I can access this strings like this: NSString *translated; translated = NSLocalizedString(@"Hello", @"User greetings"); NSLog(@"Translated text is %@",translated); My problem is allowing the user to switch language. I have create an es.lproj with the Localizable.strings file (in Spanish), but I CANT access it. I've tried this line: [[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"es", nil] forKey:@"AppleLanguages"]; But that only works the NEXT time you load the application. Is there no way to allow the user to switch languages while running the application?? Do I have to implement my own Dictionary files and forget all about NSLocalizableString family? Thanks for ANY advice or pointers. Gonso

    Read the article

  • Mac OS X Status Bar Application - Hiding it from Cmd/Alt menu?

    - by Moddy
    I'm trying to whip up a simple little Status Bar Application in Obj-C/Cocoa. So I have done it pragmatically - declaring an NSStatusItem, adding it to the NSStatusBar and then giving it a NSMenu object. A bit like this... NSStatusBar *bar = [NSStatusBar systemStatusBar]; theItem = [bar statusItemWithLength:NSVariableStatusItemLength]; [theItem retain]; [theItem setTitle: NSLocalizedString(@"Tablet",@"")]; [theItem setHighlightMode:YES]; [theItem setMenu:theMenu]; (Example taken from "Status Bar Programming Topics", Apple Documentation) Now ideally, I'd like this application to run and not be accessible from the CMD/ALT window changing "menu" (for lack of a better word), I've seen applications do it before and would like that really. The idea is I just want it to be accessible from every window, whilst not having its own NSMenu on the status bar, and whilst not being able to have it as the active application ( - so its not able to take over the whole Status Bar, and its not able to be seen through CMD/ALT) Additionally, I was wondering if the StatusBarItem supports the ability to drag-n-drop an item onto it? I'm not sure if thats a limitation of the NSStatusBar though. I've read up on deamons and agents, but that seems far too low level/over kill for such a simplistic app! Cheers in advance!

    Read the article

  • Objective-C: properties not being saved or passed

    - by Gerald Yeo
    Hi, i'm a newbie to iphone development. I'm doing a navigation-based app, and I'm having trouble passing values to a new view. @interface RootViewController : UITableViewController { NSString *imgurl; NSMutableArray *galleryArray; } @property (nonatomic, retain) NSString *imgurl; @property (nonatomic, retain) NSMutableArray *galleryArray; - (void)showAll; @end #import "RootViewController.h" #import "ScrollView.h" #import "Model.h" #import "JSON/JSON.h" @implementation RootViewController @synthesize galleryArray, imgurl; - (void)viewDidLoad { UIBarButtonItem *showButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Show All", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(showAll)] autorelease]; self.navigationItem.rightBarButtonItem = showButton; NSString *jsonString = [[Model sharedInstance] jsonFromURLString:@"http://www.ddbstaging.com/gerald/gallery.php"]; NSDictionary *resultDictionary = [jsonString JSONValue]; if (resultDictionary == nil) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Webservice Down" message:@"The webservice you are accessing is currently down. Please try again later." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } else { galleryArray = [[NSMutableArray alloc] init]; galleryArray = [resultDictionary valueForKey:@"gallery"]; imgurl = (NSString *)[galleryArray objectAtIndex:0]; NSLog(@" -> %@", galleryArray); NSLog(imgurl); } } - (void)showAll { NSLog(@" -> %@", galleryArray); NSLog(imgurl); ScrollView *controller = [[ScrollView alloc] initWithJSON:galleryArray]; [self.navigationController pushViewController:controller animated:YES]; } The RootViewController startup and the json data loads up fine. I can see it from the first console trace. However, once I click on the Show All button, the app crashes. It doesn't even trace the galleryArray and imgurl properyly. Maybe additional pairs of eyes can spot my mistakes. Any help is greatly appreciated! [Session started at 2010-05-08 16:16:07 +0800.] 2010-05-08 16:16:07.242 Photos[5892:20b] -> ( ) GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:11:58 UTC 2009) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 5892. (gdb)

    Read the article

  • EXC_BAD_ACCESS when scrolling table after json data is imported

    - by Michael Robinson
    Hello, I'm having a bear of a time trying to figure out why I'm getting a EXC_BAD ACCESS error. The console is giving me this eror: " -[CFArray objectAtIndex:]: message sent to deallocated instance 0x3b14110", I Can't figure it out...Thanks in advance. // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [rows count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. NSDictionary *dict = [rows objectAtIndex: indexPath.row]; cell.textLabel.text = [dict objectForKey:@"name"]; cell.detailTextLabel.text = [dict objectForKey:@"age"]; return cell; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0/255.0 green:207.0/255.0 blue:255.0/255.0 alpha:1.0]; self.title = NSLocalizedString(@"How Big Now", @"How Big Now"); NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"]; NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url]; // NSLog(jsonreturn); // Look at the console and you can see what the restults are NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; // In "real" code you should surround this with try and catch NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rows = [dict objectForKey:@"member"]; } NSLog(@"Array: %@",rows); [jsonreturn 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 { [super dealloc]; } @end

    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

  • Iphone App deve- Very basic table view but getting errors , trying for 2 days!! just for info using

    - by user342451
    Hi guys, trying to write this code since 2 days now, but i keep getting error, it would be nice if anyone could sort this out, thanks. Basically its the same thing i doing from the tutorial on youtube. awaiting a reply // // BooksTableViewController.m // Mybooks // // import "BooksTableViewController.h" import "BooksDetailViewController.h" import "MYbooksAppDelegate.h" @implementation BooksTableViewController @synthesize BooksArray; @synthesize BooksDetailViewController; /* - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { // Initialization code } return self; } */ (void)viewDidLoad { [super viewDidLoad]; self.title = NSLocalizedString(@"XYZ",@"GOD is GREAT"); NSMutableArray *array = [[NSArray alloc] initWithObjects:@"H1",@"2",@"3",nil]; self.booksArray = array; [array release]; } /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } pragma mark Table view methods (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.booksArray count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identity = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identity]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:identity] autorelease]; } // Set up the cell... cell.textLabel.text = [booksArray objectAtIndex:indexPath.row]; return cell; } /* - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { booksDetailsViewControler *NC = [[booksDetailsViewControler alloc] initWithNibName:@"BooksDetailsView" bundle:nil]; [self.navigationController pushViewController:NC animated:YES]; //[booksDetailViewController changeProductText:[booksArray objectAtIndex:indexPath.row]]; } */ NSInteger row = [indexPath row]; if (self.booksDetailViewController == nil) { BooksiDetailViewController *aCellDetails = [[AartiDetailViewController alloc] initWithNibName:@" BooksDetailViewController" bundle:nil]; self.booksDetailViewController = aCellDetails; [aCellDetails release]; } booksDetailViewController.title = [NSString stringWithFormat:@"%@", [booksArray objectAtIndex:row]]; //DailyPoojaAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; //[delegate.AartiNavController pushViewController:aartiDetailsViewControler animated:YES]; [self.navigationController pushViewController:aartiDetailViewController animated:YES]; } /* NSInteger row = [indexPath row]; if (self.booksDetailsViewControler == nil) { AartiDetailsViewControler *aBookDetail = [[BooksDetailsViewControler alloc] initWithNibName:@"booksDetaislView" bundle:nil]; self.booksDetailsViewControler = aBookDetail; [aBookDetail release]; } booksDetailsViewControler.title = [NSString stringWithFormat:@"%@", [booksArray objectAtIndex:row]]; [self.navigationController pushViewController:booksDetailsViewControler animated:YES]; */ (void)dealloc { [aartiDetailViewController release]; [super dealloc]; } @end

    Read the article

  • Very basic table view but getting errors

    - by user342451
    Hi guys, trying to write this code since 2 days now, but i keep getting error, it would be nice if anyone could sort this out, thanks. Basically its the same thing i doing from the tutorial on youtube. awaiting a reply // // BooksTableViewController.m // Mybooks // // #import "BooksTableViewController.h" #import "BooksDetailViewController.h" #import "MYbooksAppDelegate.h" @implementation BooksTableViewController @synthesize BooksArray; @synthesize BooksDetailViewController; /* - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { // Initialization code } return self; } */ - (void)viewDidLoad { [super viewDidLoad]; self.title = NSLocalizedString(@"XYZ",@"GOD is GREAT"); NSMutableArray *array = [[NSArray alloc] initWithObjects:@"H1",@"2",@"3",nil]; self.booksArray = array; [array release]; } /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.booksArray count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identity = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identity]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:identity] autorelease]; } // Set up the cell... cell.textLabel.text = [booksArray objectAtIndex:indexPath.row]; return cell; } /* - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { booksDetailsViewControler *NC = [[booksDetailsViewControler alloc] initWithNibName:@"BooksDetailsView" bundle:nil]; [self.navigationController pushViewController:NC animated:YES]; //[booksDetailViewController changeProductText:[booksArray objectAtIndex:indexPath.row]]; } */ NSInteger row = [indexPath row]; if (self.booksDetailViewController == nil) { BooksiDetailViewController *aCellDetails = [[AartiDetailViewController alloc] initWithNibName:@" BooksDetailViewController" bundle:nil]; self.booksDetailViewController = aCellDetails; [aCellDetails release]; } booksDetailViewController.title = [NSString stringWithFormat:@"%@", [booksArray objectAtIndex:row]]; //DailyPoojaAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; //[delegate.AartiNavController pushViewController:aartiDetailsViewControler animated:YES]; [self.navigationController pushViewController:aartiDetailViewController animated:YES]; } /* NSInteger row = [indexPath row]; if (self.booksDetailsViewControler == nil) { AartiDetailsViewControler *aBookDetail = [[BooksDetailsViewControler alloc] initWithNibName:@"booksDetaislView" bundle:nil]; self.booksDetailsViewControler = aBookDetail; [aBookDetail release]; } booksDetailsViewControler.title = [NSString stringWithFormat:@"%@", [booksArray objectAtIndex:row]]; [self.navigationController pushViewController:booksDetailsViewControler animated:YES]; */ - (void)dealloc { [aartiDetailViewController release]; [super dealloc]; } @end

    Read the article

  • iphone Dev - activity indicator with NSThread not working on Nav controller table view

    - by Frames84
    I really can't get this to work, basically when my JSON feeds loads I want the indicator to show, then hide when it's stopped. It loads top level menu items 1st "Publishing, Broadcasting, Marketing Services", then when Broadcasting is selected it loads a feed using the JSON framework hosted on Google. Round this load I call startIndicator and stopIndicator using the NSThread. Have I missed something? @implementation GeneralNewsTableViewController @synthesize dataList; @synthesize generalNewsDetailViewController; @synthesize atLevel; -(void) startIndicator { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init ]; [(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView startAnimating]; [pool release]; } -(void) stopIndicator { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init ]; [(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView stopAnimating]; [pool release]; } - (void)viewDidLoad { NSMutableArray *checker = self.dataList; if(checker == nil) { self.title = NSLocalizedString(@"General1",@"General News"); NSMutableArray *array = [[NSArray alloc] initWithObjects:@"Publishing", @"Broadcasting",@"Marketing Services",nil]; self.dataList = [array retain]; self.atLevel = @"level1"; [array release]; } UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; //set the initial property [activityIndicator stopAnimating]; [activityIndicator hidesWhenStopped]; //Create an instance of Bar button item with custome view which is of activity indicator UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator]; //Set the bar button the navigation bar [self navigationItem].rightBarButtonItem = barButton; //Memory clean up [activityIndicator release]; [barButton release]; [super viewDidLoad]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *level = self.atLevel; if([level isEqualToString:@"level2"]) { return 70.0f; } else { return 40.0f; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *FirstLevelCell = @"FirstLevelCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:FirstLevelCell] autorelease]; } NSInteger row = [indexPath row]; NSString *level = self.atLevel; if([level isEqualToString:@"level2"]) { NSMutableArray *stream = [self.dataList objectAtIndex:row]; NSString *newsTitle = [stream valueForKey:@"title"]; if( ![newsTitle isKindOfClass:[NSString class]] ) { cell.textLabel.text = @""; } else { cell.textLabel.text = [stream valueForKey:@"title"]; } cell.textLabel.numberOfLines = 2; cell.textLabel.font =[UIFont systemFontOfSize:10]; cell.detailTextLabel.numberOfLines = 1; cell.detailTextLabel.font= [UIFont systemFontOfSize:8]; cell.detailTextLabel.text = [stream valueForKey:@"created"]; NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.how-do.co.uk/images/stories/Cimex.jpg"]]; UIImage *newsImage = [[UIImage alloc] initWithData:imageURL]; cell.imageView.image = newsImage; [imageURL release]; [newsImage release]; } else { cell.textLabel.text = [dataList objectAtIndex:row]; } return cell; } - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; NSMutableString *levelType = (NSMutableString *) [dataList objectAtIndex:row]; if(![levelType isKindOfClass:[NSString class]]) { if(self.generalNewsDetailViewController == nil) { GeneralNewsDetailViewController *generalDetail = [[GeneralNewsDetailViewController alloc] initWithNibName:@"GeneralNewsDetailView" bundle:nil]; self.generalNewsDetailViewController = generalDetail; [generalDetail release]; } NSDictionary *stream = [self.dataList objectAtIndex:row]; NSString *newsTitle = [stream valueForKey:@"title"]; if( ![newsTitle isKindOfClass:[NSString class]] ) { generalNewsDetailViewController.newsTitle = @""; } else { generalNewsDetailViewController.newsTitle =[stream valueForKey:@"title"]; } generalNewsDetailViewController.newsId = [stream valueForKey:@"id"]; generalNewsDetailViewController.fullText = [stream valueForKey:@"fulltext"]; generalNewsDetailViewController.newsImage = [stream valueForKey:@"images"]; generalNewsDetailViewController.created = [stream valueForKey:@"created"]; HowDo_v1AppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.generalNewsNavController pushViewController:self.generalNewsDetailViewController animated:YES]; } else { GeneralNewsTableViewController *generalSubDetail = [[GeneralNewsTableViewController alloc] initWithNibName:@"GeneralNewsTableView" bundle:nil]; NSMutableArray *array; NSString *titleSelected = (NSString *) [dataList objectAtIndex:row]; if([titleSelected isEqualToString:@"Publishing"]) { generalSubDetail.title = @"Publishing news detail"; array = [[NSArray alloc] initWithObjects:@"pub News1", @"pub News2",@"pub News3",nil]; generalSubDetail.atLevel = @"level1"; } else if ([titleSelected isEqualToString:@"Broadcasting"]) { generalSubDetail.title = @"Broadcasting news detail"; /// START [self performSelectorOnMainThread:@selector(startIndicator) withObject:nil waitUntilDone:YES]; if(jSONDataAccessWrapper == nil) { jSONDataAccessWrapper = [JSON_DataAccess_Wrapper alloc]; } array = [jSONDataAccessWrapper downloadJSONFeed]; [self performSelectorOnMainThread:@selector(stopIndicator) withObject:nil waitUntilDone:YES]; generalSubDetail.atLevel = @"level2"; } else if ([titleSelected isEqualToString:@"Marketing Services"]) { generalSubDetail.title = @"Marketing Services news detail"; array = [[NSArray alloc] initWithObjects:@"Marketing News1", @"Marketing News2",@"Marketing News3",nil]; generalSubDetail.atLevel = @"level1"; } generalSubDetail.dataList = array; [self.navigationController pushViewController:generalSubDetail animated:YES]; [titleSelected release]; } } - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section //- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSIndexPath *) section { return [self.dataList count]; } Cheers for any feedback Frames

    Read the article

  • UITableView not displaying parsed data

    - by Graeme
    I have a UITableView which is setup in Interface Builder and connected properly to its class in Xcode. I also have a "Importer" Class which downloads and parses an RSS feed and stores the information in an NSMutableArray. However I have verified the parsing is working properly (using breakpoints and NSlog) but no data is showing in the UITable View. Any ideas as to what the problem could be? I'm almost out of them. It's based on the XML performance Apple example. Here's the code for TableView.h: #import <UIKit/UIKit.h> #import "IncidentsImporter.h" @class SongDetailsController; @interface CurrentIncidentsTableViewController : UITableViewController <IncidentsImporterDelegate>{ NSMutableArray *incidents; SongDetailsController *detailController; UITableView *ctableView; IncidentsImporter *parser; } @property (nonatomic, retain) NSMutableArray *incidents; @property (nonatomic, retain, readonly) SongDetailsController *detailController; @property (nonatomic, retain) IncidentsImporter *parser; @property (nonatomic, retain) IBOutlet UITableView *ctableView; // Called by the ParserChoiceViewController based on the selected parser type. - (void)beginParsing; @end And the code for .m: #import "CurrentIncidentsTableViewController.h" #import "SongDetailsController.h" #import "Incident.h" @implementation CurrentIncidentsTableViewController @synthesize ctableView, incidents, parser, detailController; #pragma mark - #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; self.parser = [[IncidentsImporter alloc] init]; parser.delegate = self; [parser start]; UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(beginParsing)]; self.navigationItem.rightBarButtonItem = refreshButton; [refreshButton release]; // Uncomment the following line to preserve selection between presentations. //self.clearsSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } - (void)viewWillAppear:(BOOL)animated { NSIndexPath *selectedRowIndexPath = [ctableView indexPathForSelectedRow]; if (selectedRowIndexPath != nil) { [ctableView deselectRowAtIndexPath:selectedRowIndexPath animated:NO]; } } // This method will be called repeatedly - once each time the user choses to parse. - (void)beginParsing { NSLog(@"Parsing has begun"); //self.navigationItem.rightBarButtonItem.enabled = NO; // Allocate the array for song storage, or empty the results of previous parses if (incidents == nil) { NSLog(@"Grabbing array"); self.incidents = [NSMutableArray array]; } else { [incidents removeAllObjects]; [ctableView reloadData]; } // Create the parser, set its delegate, and start it. self.parser = [[IncidentsImporter alloc] init]; parser.delegate = self; [parser start]; } /* - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } */ /* - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } */ /* - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } */ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Override to allow orientations other than the default portrait orientation. return YES; } #pragma mark - #pragma mark Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [incidents count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Table Cell Sought"); static NSString *kCellIdentifier = @"MyCell"; UITableViewCell *cell = [ctableView dequeueReusableCellWithIdentifier:kCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier] autorelease]; cell.textLabel.font = [UIFont boldSystemFontOfSize:14.0]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } cell.textLabel.text = @"Test";//[[incidents objectAtIndex:indexPath.row] title]; return cell; } /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ /* // Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } } */ /* // Override to support rearranging the table view. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { } */ /* // Override to support conditional rearranging of the table view. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the item to be re-orderable. return YES; } */ #pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { self.detailController.incident = [incidents objectAtIndex:indexPath.row]; [self.navigationController pushViewController:self.detailController animated:YES]; } #pragma mark - #pragma mark Memory management - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Relinquish ownership any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. // For example: self.myOutlet = nil; } - (void)parserDidEndParsingData:(IncidentsImporter *)parser { [ctableView reloadData]; self.navigationItem.rightBarButtonItem.enabled = YES; self.parser = nil; } - (void)parser:(IncidentsImporter *)parser didParseIncidents:(NSArray *)parsedIncidents { //[incidents addObjectsFromArray: parsedIncidents]; // Three scroll view properties are checked to keep the user interface smooth during parse. When new objects are delivered by the parser, the table view is reloaded to display them. If the table is reloaded while the user is scrolling, this can result in eratic behavior. dragging, tracking, and decelerating can be checked for this purpose. When the parser finishes, reloadData will be called in parserDidEndParsingData:, guaranteeing that all data will ultimately be displayed even if reloadData is not called in this method because of user interaction. if (!ctableView.dragging && !ctableView.tracking && !ctableView.decelerating) { self.title = [NSString stringWithFormat:NSLocalizedString(@"Top %d Songs", @"Top Songs format"), [parsedIncidents count]]; [ctableView reloadData]; } } - (void)parser:(IncidentsImporter *)parser didFailWithError:(NSError *)error { // handle errors as appropriate to your application... } - (void)dealloc { [super dealloc]; } @end

    Read the article

< Previous Page | 1 2 3  | Next Page >