Search Results

Search found 664 results on 27 pages for 'viewdidload'.

Page 5/27 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Trying to debug a 'Assertion failure in -[UIActionSheet showInView:]' error....

    - by dsobol
    I am working through "Beginning iPad Application Development" and am getting hung up in Chapter 3 where I have created a project that works with an Action Sheet. As it stands now, my application loads into the simulator just fine with no errors that I am aware of, but as it runs, it crashes with the following errors showing up in the debugger window: 2010-05-31 19:44:39.703 UsingViewsActionSheet[49538:207] * Assertion failure in -[UIActionSheet showInView:], /SourceCache/UIKit_Sim/UIKit-1145.66/UIAlert.m:7073 2010-05-31 19:44:39.705 UsingViewsActionSheet[49538:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: view != nil' I am sure that this is the block where the app breaks based upon my use of breakpoints. //Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"This is my Action Sheet!" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:@"Delete Message!" otherButtonTitles:@"Option 1", @"Option 2", @"Option 3", nil]; [action showInView:self.view]; // <-- This line seems to trigger the crash.... [action release]; [super viewDidLoad]; } Am I missing something obvious, or is there more to the problem than is shown here? I have looked at the abstract for showInView and cannot divine anything there yet. I appreciate any and all asssitance. Regards, Steve O'Sullivan

    Read the article

  • iPhone app stopped building crash reports

    - by BankStrong
    My app formerly created useful crash logs. I synced my iPhone in the past and found crash logs in library/logs/CrashReporter About a month ago, my app stopped creating crash reports. When I first discovered this problem, I assumed it was due to memory corruption (a possibility in my app). I just created a new project and added a crash to it. // Implement viewDidLoad to do additional setup after loading the view, // typically from a nib. - (void)viewDidLoad { NSMutableArray *array = [[NSMutableArray alloc] init]; [array removeObjectAtIndex:-1]; [super viewDidLoad]; } This app does not create a crash report either. Ideas I've started to explore: My phone is corrupted (tried restoring - somehow I brought it to the state from a few months ago) My XCode is corrupt (tried reinstalling, but current download demands Snow Leopard - and I can't upgrade to Snow Leopard online). This seems possible - I may have messed with device support around a month ago (similar to http://stackoverflow.com/questions/1224867/does-iphone-os-3-0-1-ruin-your-development-phone ) The location for crash logs has somehow moved. Suggestions?

    Read the article

  • Cannot show scene with Cocos2D when using UITabBarController

    - by gw1921
    Hi I'm new to Cocos2D but am having serious issues when trying to load a cocos scene in one of the UIViewControllers mixed with other normal UIKit UIViewControllers. My project uses a UITabBarController to manage four view controllers. Three are normal UIKit view controllers while one of them I want to use cocos2D for (to draw some sprites and animate them). The following is what I've done so far. In the applicationDidFinishLaunching method, I initialize cocos2D to use the window and take the first tabbarcontroller view: - (void)applicationDidFinishLaunching:(UIApplication *)application { if( ! [CCDirector setDirectorType:CCDirectorTypeDisplayLink] ) { [CCDirector setDirectorType:CCDirectorTypeDefault]; } [[CCDirector sharedDirector] setPixelFormat:kPixelFormatRGBA8888]; [CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888]; [[CCDirector sharedDirector] setDisplayFPS:YES]; [[CCDirector sharedDirector] attachInView: window]; [[[CCDirector sharedDirector] openGLView] addSubview: tabBarController.view]; [window makeKeyAndVisible]; } Then in the third UIViewController code (where I want to use cocos2D) I do this (note: the view is being loaded from a NIB file which has a blank UIView and nothing else):\ - (void)viewDidLoad { [super viewDidLoad]; // 'scene' is an autorelease object. CCScene *myScene = [CCScene node]; // 'layer' is an autorelease object. MyLayer *myLayer = [MyLayer node]; // add layer as a child to scene [myScene addChild: myLayer]; [[CCDirector sharedDirector] runWithScene: myScene]; } However all I see is a blank white view and nothing else. If I call the following in viewdidLoad: [[CCDirector sharedDirector] attachInView: self.view]; The app crashes complaining that CCDirector is already attached. Please help!

    Read the article

  • UITableView madness

    - by kesrut
    Hello, I'm new to iPhone application development. I'm trying to understand how to use UITableView. I'm wrote simple code: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1 ; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } cell.textLabel.text = @"Hello"; return cell; } UITable shows content, but if i'm drag table contents my application terminates. You can see video: http://www.youtube.com/watch?v=TucTVJVhSD0 I tried to everything with array: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1 ; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [hello count] ; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } cell.textLabel.text = [hello objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:NO]; NSLog(@"Selected") ; } - (void) awakeFromNib { hello = [[NSArray alloc] initWithObjects:@"hello", @"world", @"end", nil]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } Content is shown and if I'm selecting item i'm getting: [Session started at 2010-03-16 19:21:48 +0200.] 2010-03-16 19:21:52.295 ViewTest[1775:207] * -[ViewTestViewController respondsToSelector:]: message sent to deallocated instance 0x3911ec0 I'm total new to iPhone programming. And as i see everything i do - i'm just getting application terminated ..

    Read the article

  • Should I release NSString before assigning a new value to it?

    - by Elliot Chen
    Hi, Please give me some suggestions about how to change a NSString variable. At my class, I set a member var: NSString *m_movieName; ... @property(nonatomic, retain) NSString *m_movieName; At viewDidLoad method, I assign a default name to this var: -(void)viewDidLoad{ NSString *s1 = [[NSString alloc] initWithFormat:@"Forrest Gump"]; self.m_movieName = s1; ... [s1 release]; [super viewDidLoad] } At some function, I want to give a new name to this var, so I did like: -(void)SomeFunc{ NSString *s2 = [[NSString alloc] initWithFormat:@"Brave Heart"]; //[self.movieName release]; // ??????? Should perform here? self.m_moiveName = s2; [s2 release]; } I know, NSString* var is just a pointer to an allocated memory block, and 'assign' operation will increment this memory block's using count. For my situation, should I release m_movieName before assigning a value to it? If I do not release it (via [self.movieName release]), when and where will the previous block be released? Thanks for your help very much!

    Read the article

  • should variable be released or not? iphone-sdk

    - by psebos
    Hi, In the following piece of code (from a book) data is an NSDictionary *data; defined in the header (no property). In the viewDidLoad of the controller the following occurs: - (void)viewDidLoad { [super viewDidLoad]; NSArray *keys = [NSArray arrayWithObjects:@"home", @"work", nil]; NSArray *homeDVDs = [NSArray arrayWithObjects:@"Thomas the Builder", nil]; NSArray *workDVDs = [NSArray arrayWithObjects:@"Intro to Blender", nil]; NSArray *values = [NSArray arrayWithObjects:homeDVDs, workDVDs, nil]; data = [[NSDictionary alloc] initWithObjects:values forKeys:keys]; } Since I am really new to objective-c can someone explain to me why I do not have to retain the variables keys,homeDVDs,workDVDs and values prior exiting the function? I would expect prior the data allocation something like: [keys retain]; [homeDVDs retain]; [workDVDs retain]; [values retain]; or not? Does InitWithObjects copies (recursively) all objects into a new table? Assuming we did not have the last line (data allocation) should we release all the NSArrays prior exiting the function (or we could safely assumed that all NSArrays will be autoreleased since there is no alloc for each one?) Thanks!!!!

    Read the article

  • Navigation Items in UITableViewController are not appearing?

    - by Sheehan Alam
    I am displaying a UITableViewController inside of a UITabBarController that is being presented modally: -(IBAction)arButtonClicked:(id)sender{ //this is a uitableviewcontroller ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]autorelease]; LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease]; lbViewController.title = @"Leaderboard"; arTabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; arTabBarController.viewControllers = [NSArray arrayWithObjects:arViewController, lbViewController, nil]; arTabBarController.selectedViewController = arViewController; [self presentModalViewController:arTabBarController animated:YES]; } In my viewDidLoad for arViewController method I am setting the navigation items: - (void)viewDidLoad { [super viewDidLoad]; // Uncomment the following line to preserve selection between presentations. self.clearsSelectionOnViewWillAppear = NO; self.title = @"AR"; leaderBoardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(leaderBoardButtonClicked:)]; self.navigationItem.rightBarButtonItem = leaderBoardButton; } My navigation bar doesn't appear when it is inside of the UITabBarController, but when I push the view itself I am able to see it. What am I missing?

    Read the article

  • Iphone - UIView not displayed

    - by Raphael Pinto
    Hi, I have a strange problem with a UIView : I want to show an Activity Indicator View that I created with Interface Builder to indicate long running activity. In the viewDidLoad function of my principal viewController I init the ActivityIndicator View like this : - (void)viewDidLoad { [super viewDidLoad]; appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; load = [[ActivityIndicatorViewController alloc] init]; ... When I push a button it call this IBAction : - (IBAction)LaunchButtonPressed{ // Show the Activity indicator view. [self.view addSubview:load.view]; // eavy work [self StartWorking]; // Hide the loading view. [load.view removeFromSuperview]; } In the StartWorking function, I ask a request to an internet serveur and parse the XML file that it return me. The problem is that if I Call my StartWorking function, the application do not start by showing the Activity Indicator view but with the StartWorking function. Whereas if I remove the call to StartWorking function, the view is shown. Is someone able to explain me why? :s

    Read the article

  • when an autoreleased object is actually released?

    - by psebos
    Hi, I am new in objective-c and I am trying to understand memory management to get it right. After reading the excellent Memory Management Programming Guide for Cocoa by apple my only concern is when actually an autoreleased object is released in an iphone/ipod application. My understanding is at the end of a run loop. But what defines a run loop in the application? So I was wondering whether the following piece of code is right. Assume an object @implementation Test - (NSString *) functionA { NSString *stringA; stringA = [[NSString alloc] initWithString:@"Hello" autorelease] return stringA; } - (NSString *) functionB { NSString *stringB; stringB = [self functionA]; return stringB; } - (NSString *) functionC { NSString *stringC; stringC = [self functionB]; return stringC; } - (void)viewDidLoad { [super viewDidLoad]; (NSString *) p = [self functionC]; NSLog(@"string is %@",p); } @end Is this code valid? From the apple text I understand that the NSString returned from functionA is valid in the scope of functionB. I am not sure whether it is valid in functionC and in viewDidLoad. Thanks!

    Read the article

  • Why is my UITableView not being set?

    - by Jamie L
    I checked using the debbuger in the viewDidLoad method and tracerTableView is 0x0 which i assume means it is nil. I don't understand. I should go ahaed say yes I have already checked my nib file and yes all the connections are correct. Here is the header file and the begging of the .m. ///////////// .h file //////////// @interface TrackerListController : UITableViewController { // The mutable (modifiable) dictionary days holds all the data for the days tab NSMutableArray *trackerList; UITableView *tracerTableView; } @property (nonatomic, retain) NSMutableArray *trackerList; @property (nonatomic, retain) IBOutlet UITableView. *tracerTableView; //The addPackage: method is invoked when the user taps the addbutton created at runtime. -(void) addPackage : (id) sender; @end /////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////// .m file ////////////////////////////////////// @implementation TrackerListController @synthesize trackerList, tracerTableView; (void)viewDidLoad { [super viewDidLoad]; self.title = @"Package Tracker"; self.navigationItem.leftBarButtonItem = self.editButtonItem; UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPackage:)]; // Set up the Add custom button on the right of the navigation bar self.navigationItem.rightBarButtonItem = addButton; [addButton release]; // Release the addButton from memory since it is no longer needed }

    Read the article

  • Why is my UIWebView not scrollable?

    - by Thomas
    In my most frustrating roadblock to date, I've come across a UIWebView that will NOT scroll! I call it via this IBAction: -(IBAction)session2ButtonPressed:(id)sender { Session2ViewController *session2View = [[Session2ViewController alloc]initWithNibName:@"Session2ViewController" bundle:nil]; self.addictionViewController = session2View; [self.view insertSubview:addictionViewController.view atIndex:[self.view.subviews count]]; [session2View release]; } In the viewDidLoad of Session2ViewController.m, I have - (void)viewDidLoad { [super viewDidLoad]; // TRP - Grab data from plist // TRP - Build file path to the plist NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Addiction" ofType:@"plist"]; // TRP - Create NSDictionary with contents of the plist NSDictionary *addictionDict = [NSDictionary dictionaryWithContentsOfFile:filePath]; // TRP - Create an array with contents of the dictionary NSArray *addictionData = [addictionDict objectForKey:@"Addiction1"]; NSLog(@"addictionData (array): %@", addictionData); // TRP - Create a string with the contents of the array NSString *addictionText = [NSString stringWithFormat:@"<DIV style='font-family:%@;font-size:%d;'>%@</DIV>", @"Helvetica", 18, [addictionData objectAtIndex:1]]; addictionInfo.backgroundColor = [UIColor clearColor]; // TRP - Load the string created and stored into addictionText and display in the UIWebView [addictionInfo loadHTMLString:addictionText baseURL:nil]; // TODO: MAKE THIS WEBVIEW SCROLL!!!!!! } In the nib, I connected my web view to the delegate and to the outlet. When I run my main project, the plist with my HTML code shows up, but does not scroll. I copied and pasted this code into a new project, wired the nib the exact same way, and badda-boom badda-bing. . . it works. I even tried to create a new nib from scratch in this project, and the exact same code would not work. Whiskey Tango Foxtrot Any ideas?? Thanks! Thomas

    Read the article

  • iphone NSMutableArray loses objects at end of method

    - by Brodie4598
    Hello - in my app, an NSMutableArray is populated with an object in viewDidLoad (eventually there will be many objects but I'm just doing one til I get it working right). I also start a timer that starts a method that needs to access the NSMutableArray every few seconds. The NSMutableArray works fine in viewDidLoad, but as soon as that method is finished, it loses the object. myApp.h @interface MyApp : UIViewController { NSMutableArray *myMutableArray; NSTimer *timer; } @property (nonatomic, retain) NSMutableArray *myMutableArray; @property (nonatomic, retain) NSTimer *timer; @end myApp.m #import "MyApp.h" @implementation MyApp @synthesize myMutableArray; - (void) viewDidLoad { cycleTimer = [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(newCycle) userInfo: nil repeats:YES]; MyObject *myCustomUIViewObject = [[MyObject alloc]init]; [myMutableArray addObject:myCustomUIViewObject]; [myCustomUIViewObject release]; NSLog(@"%i",[myMutableArray count]); /////outputs "1" } -(void) newCycle { NSLog(@"%i",[myMutableArray count]); /////outputs "0" ?? why is this?? }

    Read the article

  • how to play an audio soundclip when a nib is loaded - welcome screen - xcode

    - by Pavan
    I would like to do the following two things: 1) I would like to play an audio file qhen a nib is loaded 2) After that i would like to switch views when the audio file has finished playing. This will be easy as i just need to call the event that initiates the change of view by using the delegate method -(void) audioPlayerDidFinishPlaying{ //code to change view } I dont know how to to play the audio file when a nib is loaded. Using the AVFoundation framework, I tried doing the following after setting up the audio player and the variables associated with it in the appropriate places i wrote the following: - (void)viewDidLoad { [super viewDidLoad]; NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"sound" ofType: @"mp3"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error:nil]; [fileURL release]; self.player = newPlayer; [newPlayer release]; [player prepareToPlay]; [player setDelegate: self]; [player play]; } Although this does not play the file as the viewdidload method gets called before the nib is shown so the audio is never played or heard. What do i need to do so that i can play the audio file AFTER the nib has loaded and is shown on the screen? can someone please help me as ive been working on this for 3 hours now. Thanks in advance.

    Read the article

  • How do I reference my MainViewController from another class?

    - by todd412
    Hi, I am building an iPhone Utility app that uses UIImageView to display an animation. Within the MainViewController's viewDidLoad() method, I am creating an instance of a CustomClass, and then setting up the animations: - (void)viewDidLoad { [super viewDidLoad]; cc = [CustomClass new]; NSArray * imageArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"image-1-off.jpg"], [UIImage imageNamed:@"image-2-off.jpg"], [UIImage imageNamed:@"image-3-off.jpg"], [UIImage imageNamed:@"image-4-off.jpg"], nil]; offSequence = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; offSequence.animationImages = imageArray; offSequence.animationDuration = .8; offSequence.contentMode = UIViewContentModeBottomLeft; [self.view addSubview:offSequence]; [offSequence startAnimating]; } That works fine. However, I would like to be able to move all the above code that sets up the UIImageView into my CustomClass. The problem is in the second to last line: [self.view addSubview:offSequence]; I basically need to replace 'self' with a reference to the MainControllerView, so I can call addSubview from within my CustomClass. I tried creating an instance var of CustomClass called mvc and a setter method that takes a reference to the MainViewController as an argument as such: - (void) setMainViewController: (MainViewController *) the_mvc { mvc = the_mvc; } And then I called it within MainViewController like so: [cc setMainController:MainViewController:self]; But this yields all sorts of errors which I can post here, but it strikes me that I may be overcomplicating this. Is there an easier way to reference the MainViewController that instanatiated my CustomClass?

    Read the article

  • How can I remove the present view when I have added more than one subView ?

    - by srikanth rongali
    How can I remove the present view when I touched the close button. I did [self.view removeFromSuperView] when I added only one subView. It worked. But, I have now added another subView to the previous subView. I need to to get the parent view . How can I do it. My code of adding the subView is here. When I did the following only one view is removed. //FirstViewController: UIViewController -(void)libraryFunction:(id)sender { LibraryController *libraryController = [[LibraryController alloc]init]; [self.view addSubview:libraryController.view]; } //LibraryController: UIViewController -(void)viewDidLoad{ RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; self.navController = aNavigationController; [aNavigationController release]; [rootViewController release]; [self.view addSubview:navController.view]; } //RootViewController: UITableViewController - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)]; } -(void)close:(id)sender { [self.view removeFromSuperview]; } Thank You.

    Read the article

  • Very very weird problem with UIImageView property - I can access it then I can't, and it's not nil.

    - by just_another_coder
    Very very weird problem with UIImageView property on iPad application @interface MyViewController : UIViewController { IBOutlet UIImageView* coverImage; } @property(nonatomic, retain) IBOutlet UIImageView* coverImage; … more code @implementation MyViewController @synthesize coverImage; … more code - (void)viewDidLoad { [super viewDidLoad]; NSString* imageName = @"my_image.png"; UIImage* tempImage = [UIImage imageNamed:imageName]; [self.coverImage setImage:tempImage]; } The above code WILL display the image. In another part of code: -(IBAction) stopButtonPressed:(id)sender { [self.coverImage setHidden:YES]; NSLog(@"coverImage desc: %@", [coverImage description]); } The image will NOT disappear. I know the reference to the image isn't nil, because it gives me this output: 2010-05-29 17:37:40.706 MyApp[95360:207] coverImage desc: UIImageView: 0x5128420; frame = (0 0; 1024 768); autoresize = RM+BM; userInteractionEnabled = NO; layer = CALayer: 0x512bed0 In addition, if I move the code in viewDidLoad to another part of the class, and try to execute it from there, it fails to show the image at all.

    Read the article

  • iOS: display modal view over the top of a UIWebView

    - by Sly
    Is it possible to display a modal view over the top of a UIWebView? I have a UIViewController that loads a WebView. I then want to push a Modal View Controller over the top so that a modal view covers up the WebView temporarily... The WebView is working fine; here's how it's loaded in the View Controller: - (void)loadView { // Initialize webview and add as a subview to LandscapeController's view myWebView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]; myWebView.scalesPageToFit = YES; myWebView.autoresizesSubviews = YES; myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); myWebView.delegate = self; self.view = myWebView; } If I attempt to load a Modal View controller from within viewDidLoad, however, no modal view appears: - (void)viewDidLoad { [super viewDidLoad]; // Edit dcftable.html with updated figures NSMutableString *updated_html = [self _updateHTML:@"dcftable"]; // Load altered HTML file as an NSURL request [self.myWebView loadHTMLString:updated_html baseURL:nil]; // If user hasn't paid for dcftable, then invoke the covering modal view if (some_condition) { LandscapeCoverController *landscapeCoverController = [[[LandscapeCoverController alloc] init] autorelease ]; [self presentModalViewController:landscapeCoverController animated:YES]; } } I suspect that there's something that needs to be done with the UIWebView delegate to get it to receive the new modal view...but can't find any discussion or examples of this anywhere...again, the objective is to invoke a modal view that covers over the top of the WebView. Thanks for any thoughts in advance!

    Read the article

  • iPhone dev: UIBarButtonItem or title not showing up in NavigationBar

    - by IceMan85
    Hello everyone, here my problem. I have a NavigationBar at the top, a TabBar at the bottom and a TableView at the center of the screen. Very normal situation. I set it all up in IB and I have set this in the app delegate : ExpensesListNavController *expensesListNavController; This in order to be able to add new views to the stack. I need to have 3 levels: - list of items in a TableView - OK - firstLevel: once pressed one cell a view is added to the stack - OK - second level: one pressed the "modify" button on the navBar on the firstLevel I want to show a new view that can be customized by the user. My Problem is coming when trying to add the "Modify" button in the "firstLevelView". Here-below my code -(IBAction) modify:(id)sender { if (editableDetailViewController == nil) { editableDetailViewController = [[editableDetailViewController alloc] init]; } editableDetailViewController.expense = expense; [appDelegate.expensesListNavController pushViewController:editableDetailViewController animated:YES]; editableDetailViewController = nil; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; appDelegate = [[UIApplication sharedApplication] delegate]; UIBarButtonItem *modifyButton = [[UIBarButtonItem alloc] initWithTitle:@"Modify" style:UIBarButtonItemStylePlain target:self action:@selector(modify:)]; appDelegate.expensesListNavController.navigationItem.rightBarButtonItem = modifyButton; appDelegate.expensesListNavController.navigationItem.title = @"Titoloooo"; NSLog(@"NavBar button has just been set !!"); [modifyButton release]; Nothing is being showed, neither title nor the button. Do you have any idea of what is happening ?? I really cannot figure out !!! Thanks a lot in advance, AM

    Read the article

  • iPhone SDK: How to center map around a particular point?

    - by buzzappsoftware
    New to MapKit. Having problems centering map around a specified point. Here is the code. Not sure why this is not working. We are expecting to see a map centered around Cincinnati, OH. What we are seeing is the default google map of the world. Any help appreciated. / Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; CLLocationCoordinate2D mapCoords[2]; mapCoords[0].latitude = 39.144057; mapCoords[0].latitude = -84.505484; mapCoords[1].latitude = 39.142984; mapCoords[1].latitude = -84.502534; MKCoordinateSpan span; span.latitudeDelta = 0.2; span.longitudeDelta = 0.2; MKCoordinateRegion region; region.center = mapCoords[0]; region.span = span; [mapView setRegion:region animated:YES]; }

    Read the article

  • UITableView populating EVERY OTHER launch

    - by Joshmattvander
    I am having a problem that I cant seem to get to the bottom of. In my view did load code, I am creating an array and attempting to populate the table. For some reason it only populates the data on EVERY OTHER time the app is run. I put logs in viewDidLoad which runs as does viewWillAppear and outputs the correct count for the array. Also, the UITableView specicic methods get called when it works and they just don't get called when it doesnt work. I cant figure out the root of this problem. Again this occurrence happens exactly 50% of the time. Theres no dynamic data that could be tripping up or anything. #import "InfoViewController.h" @implementation InfoViewController - (void)viewDidLoad { NSLog(@"Info View Loaded"); // This runs infoList = [[NSMutableArray alloc] init]; //Set The Data //Theres 8 similar lines [infoList addObject :[[NSMutableDictionary alloc] initWithObjectsAndKeys: @"Scrubbed", @"name", @"scrubbed", @"url", nil]]; NSLog(@"%d", [infoList count]); // This shows the count correctly every time [super viewDidLoad]; } -(void) viewWillAppear:(BOOL)animated { NSLog(@"Info Will Appear"); // This Runs } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // This WILL NOT RUN when it doesnt work, and DOES show the count when it does run NSLog(@"Counted in numberOfRowsInSection %d", [infoList count]); return [infoList count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"ROW"); static NSString *CellIdentifier = @"infoCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.textLabel.text = [[infoList objectAtIndex:indexPath.row] objectForKey:@"name"]; return cell; } @end

    Read the article

  • TBXML parsing issue while the value cannot get in UILabel

    - by Dany
    In my app I'm using TBXML parser where I need to get a value from xml file and print it on the label. This is my xml file in server <gold> <price> <title>22 K Gold</title> </price> <price> <title>24 K Gold</title> </price> </gold> any my Viewcontroller.h looks like #import <UIKit/UIKit.h> #import "TBXML.h" @interface ViewController : UIViewController{ IBOutlet UILabel *lab; IBOutlet UILabel *lab1; TBXML *tbxml; } @end and my Viewcontrooler.m looks like - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSData *xmlData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:@"http://www.abcde.com/sample.xml"]]; tbxml = [[TBXML alloc]initWithXMLData:xmlData]; TBXMLElement * root = tbxml.rootXMLElement; if (root) { TBXMLElement * elem_PLANT = [TBXML childElementNamed:@"price" parentElement:root]; while (elem_PLANT !=nil) { TBXMLElement * elem_BOTANICAL = [TBXML childElementNamed:@"title" parentElement:elem_PLANT]; NSString *botanicalName = [TBXML textForElement:elem_BOTANICAL]; lab.text=[NSString stringWithFormat:@"re %@", botanicalName]; elem_PLANT = [TBXML nextSiblingNamed:@"price" searchFromElement:elem_PLANT]; elem_BOTANICAL = [TBXML childElementNamed:@"title" parentElement:elem_PLANT]; botanicalName = [TBXML textForElement:elem_BOTANICAL]; lab1.text=[NSString stringWithFormat:@"re %@", botanicalName]; } } } I'm getting BAD_ACCESS thread. Am I missing anything?

    Read the article

  • Observing MVC, can/should the Model be instantiated in the ViewController? Or where?

    - by user19410
    I'm writing an experimental iPhone app to learn about the MVC paradigm. I instantiate my Model class in the ViewController class. Is this stupid? I'm asking because storing the id of the Model class, and using it works where it's initialized, but referring to it later (in response to an interface action) crashes. Seemingly, the pointer address of my Model class instance changes, but how can that be? The code in question: @interface Soundcheck_Tone_GeneratorViewController : UIViewController { IBOutlet UIPickerView * frequencyWheel; @public Sinewave_Generation * sineGenerator; } @property(nonatomic,retain) Sinewave_Generation * sineGenerator; @end @implementation Soundcheck_Tone_GeneratorViewController @synthesize sineGenerator; - (void)viewDidLoad { [super viewDidLoad]; [self setSineGenerator:[[Sinewave_Generation alloc] initWithFrequency:20.0]]; // using reference -> fine } // pickerView handling is omitted here... - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { [[self sineGenerator] setFrequency:20.0]; // using reference -> crash } @end // the Sinewave_Generation class... only to be thorough. Works fine so far. @interface Sinewave_Generation : NSObject { AudioComponentInstance toneUnit; @public double frequency,theta; } @property double frequency; - (Sinewave_Generation *) initWithFrequency: (int) f; @end @implementation Sinewave_Generation @synthesize frequency; - (Sinewave_Generation *) initWithFrequency: (int) f { self = [super init]; if ( self ) { [self setFrequency: f]; } return self; } @end

    Read the article

  • How i set the background color in UIView using CGContext?

    - by Rajendra Bhole
    Hi, I have developed the application in which i want to set the background color of UIView which is already set on UIViewController.The code is below, @implementation frmGraphView /* // 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; } */ - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } 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)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextClearRect(ctx, rect); //CGContextSetCMYKFillColor(ctx, 35.0, 56.0, 34.0, 30.0, 1.0); //CGContextSetRGBFillColor(ctx, 92.0f, 95.0f, 97.0f, 1.0f); //CGContextFillRect(ctx, CGRectMake(0, 0, 300, 280)); CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0); CGContextSetLineWidth(ctx, 2.0); float fltX1,fltX2,fltY1,fltY2=0; NSArray *hoursInDays = [[NSArray alloc] initWithObjects:@"0",@"1" ,@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil]; fltX1 = 30; fltY1 = 5; fltX2 = fltX1; fltY2 = 270; //Dividing the Y-axis CGContextMoveToPoint(ctx, fltX1, fltY1); CGContextAddLineToPoint(ctx, fltX2, fltY2); //float y = 275; for(int intIndex = 0 ; intIndex < [hoursInDays count] ; fltY2-=20, intIndex++) { CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0); CGContextMoveToPoint(ctx, fltX1-3 , fltY2); CGContextAddLineToPoint(ctx, fltX1+3, fltY2); CGContextSelectFont(ctx, "Helvetica", 14.0, kCGEncodingMacRoman); CGContextSetTextDrawingMode(ctx, kCGTextFill); CGContextSetRGBFillColor(ctx, 0, 255, 255, 1); CGAffineTransform xform = CGAffineTransformMake( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); CGContextSetTextMatrix(ctx, xform); const char *arrayDataForYAxis = [[hoursInDays objectAtIndex:intIndex] UTF8String]; CGContextShowTextAtPoint(ctx, fltX1-18, fltY2-18 , arrayDataForYAxis, strlen(arrayDataForYAxis)); CGContextStrokePath(ctx); } CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0); CGContextSetLineWidth(ctx, 2.0); fltX1 = 5; fltY1 = 250; fltX2 = 270; fltY2 = fltY1; NSArray *weekDays =[[NSArray alloc] initWithObjects:@"Sun", @"Mon", @"Tus", @"Wed", @"Thu", @"Fri", @"Sat", nil]; //Dividing the X-axis CGContextMoveToPoint(ctx, fltX1, fltY1); CGContextAddLineToPoint(ctx, fltX2, fltY2); //float y = 275; for(int intIndex = 0 ; intIndex < [weekDays count] ; fltX1+=33, intIndex++) { CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0); CGContextMoveToPoint(ctx, fltX1+52 , fltY2-3); CGContextAddLineToPoint(ctx, fltX1+52, fltY2+3); CGContextSelectFont(ctx, "Arial", 15.0, kCGEncodingMacRoman); CGContextSetTextDrawingMode(ctx, kCGTextFill); CGContextSetRGBFillColor(ctx, 0, 255, 255, 1); CGAffineTransform xform = CGAffineTransformMake( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); CGContextSetTextMatrix(ctx, xform); const char *arrayDataForXAxis = [[weekDays objectAtIndex:intIndex] UTF8String]; CGContextShowTextAtPoint(ctx, fltX1+37, fltY2+18 , arrayDataForXAxis, strlen(arrayDataForXAxis)); CGContextStrokePath(ctx); } } - (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

  • Passing Variables between views / view controllers

    - by Dan
    Hi I'm new to ObjectiveC / IPhoneSDK and I'm informally trying to study it on my own. What I'm basically trying to do is from one view there are 12 zodiac signs. When a user clicks one, it proceeds to the second view (with animation) and loads the name of the zodiac sign it clicked in a UILabel, that's it. Here are my codes: Lovescopes = 1st page Horoscopes = 2nd page Lovescopes4AppDelegate.h #import <UIKit/UIKit.h> #import "HoroscopesViewController.h" #import "Lovescopes4AppDelegate.h" @class Lovescopes4ViewController; @interface Lovescopes4AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; Lovescopes4ViewController *viewController; HoroscopesViewController *horoscopesViewController; } -(void)loadHoroscope; -(void)loadMainPage; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet Lovescopes4ViewController *viewController; @property (nonatomic, retain) HoroscopesViewController *horoscopesViewController; @end Lovescopes4AppDelegate.m #import "Lovescopes4AppDelegate.h" #import "Lovescopes4ViewController.h" @implementation Lovescopes4AppDelegate @synthesize window; @synthesize viewController; @synthesize horoscopesViewController; -(void)loadHoroscope { HoroscopesViewController *aHoroscopeViewController = [[HoroscopesViewController alloc] initWithNibName:@"HoroscopesViewController" bundle:nil]; [self setHoroscopesViewController:aHoroscopeViewController]; [aHoroscopeViewController release]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; [viewController.view removeFromSuperview]; [self.window addSubview:[horoscopesViewController view]]; [UIView commitAnimations]; } -(void)loadMainPage { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:NO]; [horoscopesViewController.view removeFromSuperview]; [self.window addSubview:[viewController view]]; [UIView commitAnimations]; [horoscopesViewController release]; horoscopesViewController = nil; } - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end Lovescopes4ViewController.h #import <UIKit/UIKit.h> #import "HoroscopesViewController.h" @interface Lovescopes4ViewController : UIViewController { HoroscopesViewController *hvc; } -(IBAction)loadAries; @property (nonatomic, retain) HoroscopesViewController *hvc; @end Lovescope4ViewController.m #import "Lovescopes4ViewController.h" #import "Lovescopes4AppDelegate.h" @implementation Lovescopes4ViewController @synthesize hvc; -(IBAction)loadAries { NSString *selected =@"Aries"; [hvc loadZodiac:selected]; Lovescopes4AppDelegate *mainDelegate = (Lovescopes4AppDelegate *) [[UIApplication sharedApplication] delegate]; [mainDelegate loadHoroscope]; } HoroscopesViewController.h #import <UIKit/UIKit.h> @interface HoroscopesViewController : UIViewController { IBOutlet UILabel *zodiacLabel; } -(void)loadZodiac:(id)zodiacSign; -(IBAction)back; @property (nonatomic, retain) IBOutlet UILabel *zodiacLabel; @end HoroscopesViewController.m #import "HoroscopesViewController.h" #import "Lovescopes4AppDelegate.h" @implementation HoroscopesViewController @synthesize zodiacLabel; /* // 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)loadZodiac:(id)zodiacSign { zodiacLabel.text = [NSString stringWithFormat: @"%@", zodiacSign]; } -(IBAction)back { Lovescopes4AppDelegate *mainDelegate = (Lovescopes4AppDelegate *) [[UIApplication sharedApplication] delegate]; [mainDelegate loadMainPage]; }

    Read the article

  • NSOperation unable to load data on the TableView

    - by yeohchan
    I have a problem in NSOperation. I tried many ways but it would run behind the screen, but will not make it appear on the my table view. Can anyone help me out with this. I am new to NSOperation. Recents.h #import <UIKit/UIKit.h> #import "FlickrFetcher.h" @interface Recents : UITableViewController { FlickrFetcher *fetcher; NSString *name; NSData *picture; NSString *picName; NSMutableArray *names; NSMutableArray *pics; NSMutableArray *lists; NSArray *namelists; NSOperationQueue *operationQueue; } @property (nonatomic,retain)NSString *name; @property (nonatomic,retain)NSString *picName; @property (nonatomic,retain)NSData *picture; @property (nonatomic,retain)NSMutableArray *names; @property (nonatomic,retain)NSMutableArray *pics; @property(nonatomic,retain)NSMutableArray *lists; @property(nonatomic,retain)NSArray *namelists; @end Recents.m #import "Recents.h" #import "PersonList.h" #import "PhotoDetail.h" @implementation Recents @synthesize picName,picture,name,names,pics,lists,namelists; // 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 self.title=@"Recents"; } return self; } - (void)beginLoadingFlickrData{ NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(synchronousLoadFlickrData) object:nil]; [operationQueue addOperation:operation]; [operation release]; } - (void)synchronousLoadFlickrData{ fetcher=[FlickrFetcher sharedInstance]; NSArray *recents=[fetcher recentGeoTaggedPhotos]; [self performSelectorOnMainThread:@selector(didFinishLoadingFlickrDataWithResults:) withObject:recents waitUntilDone:NO]; } - (void)didFinishLoadingFlickrDataWithResults:(NSArray *)recents{ for(NSDictionary *dic in recents){ [names addObject:[fetcher usernameForUserID:[dic objectForKey:@"owner"]]]; if([[dic objectForKey:@"title"]isEqualToString:@""]){ [pics addObject:@"Untitled"]; }else{ [pics addObject:[dic objectForKey:@"title"]]; } NSLog(@"OK!!"); } [self.tableView reloadData]; [self.tableView flashScrollIndicators]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; operationQueue = [[NSOperationQueue alloc] init]; [operationQueue setMaxConcurrentOperationCount:1]; [self beginLoadingFlickrData]; self.tableView.rowHeight = 95; } /* // 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]; } #pragma mark - #pragma mark Table View Data Source Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return[names count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } cell.detailTextLabel.text=[names objectAtIndex:indexPath.row]; cell.textLabel.text=[pics objectAtIndex:indexPath.row]; //UIImage *image=[UIImage imageWithData:[self.lists objectAtIndex:indexPath.row]]; //cell.imageView.image=image; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { fetcher=[[FlickrFetcher alloc]init]; PhotoDetail *scroll=[[PhotoDetail alloc]initWithNibName:@"PhotoDetail" bundle:nil]; scroll.titleName=[self.pics objectAtIndex:indexPath.row]; scroll.picture = [UIImage imageWithData:[self.lists objectAtIndex:indexPath.row]]; [self.navigationController pushViewController:scroll animated:YES]; }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >