Search Results

Search found 825 results on 33 pages for 'uiviewcontroller'.

Page 21/33 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • How to determine the current view bounds in split view of Ipad App?

    - by Mahesh
    Hello friends, I have tried following code to determine current view bounds in shouldAutoRotate.. fn UIViewController *temp1 = [appDelegate.splitViewController.viewControllers objectAtIndex:1]; float screenwidth = temp1.view.bounds.size.width; float screenheight = temp1.view.bounds.size.height; bt actually when u rotate from one mode to another, it provides the bound values of old one insted the fresh bound values..? Any one know that how to achieve it?

    Read the article

  • IBOutlet on properties and exposition of the class

    - by Espuz
    Apple, for memory management issues, recommend defining outlets on properties, not in the attribute declaration. But, as far as I know, declaring properties exposes the class to external classes, so this could be dangerous. On UIViewController we have the main view definition and the logic, so MVC is slightly cheated in this cases. What is the beteer approach, Apples's recommendation for memory-management or armored classes?

    Read the article

  • UIWebView doesn't scroll to the bottom of the webpage loaded/created

    - by tom
    I have a UIWebView inside a normal UIViewController. The content of the UIWebView is programming/dynamically created in my program, and it could be very long (multiple table rows). Somehow, after loading, the page won't scroll more then one and half screen of content when swipe on the screen. Because of that I can only see the beginning few rows of data, but not the many others after them. Why is that?

    Read the article

  • UISearchBar Not appearing

    - by joec
    Hi I have view controller, into the view i have put a table view, and a search bar into the table's header... the search bar is not showing up, just the empty table view. Do i need to do something additional? I'm pretty sure its to do with the view outlet of the UIViewController, set to View... Thanks

    Read the article

  • Adding a view with a view controller as a subview of another view controller. Doesn't work.

    - by Tom
    I'm trying to essentially re-implement the UISplitViewController (because it has its limits), but when I create a UIViewController viewController, and then do an "[viewController.view addSubview contentViewController.view]" on it, to add a view that already has a view controller, that content view doesn't seem to get initialised by its view controller. I guess its view controller is getting detached or deallocated, is this the case?

    Read the article

  • TabBarController delegate is not working

    - by Zach
    Hi, Can any one help me, when i am using my UITabBarController delegate it is not working.. I called a delegate method like this.. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { [self.navigationController popToRootViewControllerAnimated:NO]; }

    Read the article

  • iPhone OS 3.2 (iPad) Modal View question

    - by user308475
    I am presenting a UIViewController as a modal viewcontroller with modalPresentationStyle = UIModalPresentationFormSheet. I have few UITextFields on its view. My issue is that when I try to dismiss the keyboard ([textfieldname resignFirstResponder]), it doesn't do anything. However when I change the modalPresentationStyle to UIModalPresentationPageSheet, it works. This seems to be a bug. Has any one faced similar problems and found a work around? Could I be doing anything dumb and silly?

    Read the article

  • AdWhirl implementation in iPhone Cocoa touch

    - by user571283
    Hi dudes, i'm starting to implement AdWhirl in my application. i follow the instructions which is belong to adwhirl but i cant see any ad in my application.i add the following methods in my viewcontroller class - (void)viewDidLoad { [super viewDidLoad]; AdWhirlView *adView=[AdWhirlView requestAdWhirlViewWithDelegate:self]; [self.view addSubview:adView]; } -(NSString *) adWhirlApplicationKey{ return @"myAdWhirlKey"; } -(UIViewController *) viewControllerForPresentingModalView{ return self; } i doesn't display anything. please help how to implement AdWhirl

    Read the article

  • need advise about NSClassFromString

    - by RAGOpoR
    according to this code i dont understand about NSClassFromString how did i know "viewControllerName" can i use it from another source ? could you please tell me more information how to use NSClassFromString? UIViewController *viewController = [[NSClassFromString(viewControllerName) alloc] init];

    Read the article

  • UIStoryboard load from app delegate

    - by Alessandro
    I am trying to load a UIStoryboard from the app delegate .m in this way: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]]; UIViewController *vc =[storybord instantiateInitialViewController]; [self.window addSubview:vc.view]; return YES; } What is the problem with this code?? any idea?

    Read the article

  • Pausing and restarting an Animation

    - by Sandeep
    I'm running a CAKeyframeAnimation in a subclass of UIViewController. I want to pause the animation on pressing a "Pause" button and start back from where it paused on pressing a "Resume" button. I've come across an answer to a similar question on this site, but it doesn't work for me. I would appreciate any help.

    Read the article

  • Same object in different nib files?

    - by Michael
    View1 object, which is UIViewController subclass is the same object as File's Owner of View1 nib. So I should manually set the class in both places, one in MainWindow and another in View1 nib files? This sound artificial to me... Either I'm doing something wrong or there has to be better way.

    Read the article

  • I can not hide keyboard by pressing return key

    - by chetan
    I have tried this: In .h file @interface TouchLabelViewController : UIViewController<UITextFieldDelegate> -(IBAction)hideKeyboard:(id)sender; In .m File -(IBAction)hideKeyboard:(id)sender{ [(UITextField*)sender resignFirstResponder]; } And also tried this in .h file -(BOOL) textFieldShouldReturn:(UITextField *)textField; in .m file -(BOOL) textFieldShouldReturn:(UITextField *)textField{ [aTextField resignFirstResponder]; return YES; } But still whenever i touch return key it does not hide keyboard.

    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

  • Multi-level navigation controller on left-hand side of UISplitView with a small twist.

    - by user141146
    Hi. I'm trying make something similar to (but not exactly like) the email app found on the iPad. Specifically, I'd like to create a tab-based app, but each tab would present the user with a different UISplitView. Each UISplitView contains a Master and a Detail view (obviously). In each UISplitView I would like the Master to be a multi-level navigational controller where new UIViewControllers are pushed onto (or popped off of) the stack. This type of navigation within the UISplitView is where the application is similar to the native email app. To the best of my knowledge, the only place that has described a decent "splitviewcontroller inside of a uitabbarcontroller" is here: http://stackoverflow.com/questions/2475139/uisplitviewcontroller-in-a-tabbar-uitabbarcontroller and I've tried to follow the accepted answer. The accepted solution seems to work for me (i.e., I get a tab-bar controller that allows me to switch between different UISplitViews). The problem is that I don't know how to make the left-hand side of the UISplitView to be a multi-level navigation controller. Here is the code I used within my app delegate to create the initial "split view 'inside' of a tab bar controller" (it's pretty much as suggested in the aforementioned link). - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSMutableArray *tabArray = [NSMutableArray array]; NSMutableArray *array = [NSMutableArray array]; UISplitViewController *splitViewController = [[UISplitViewController alloc] init]; MainViewController *viewCont = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil]; [array addObject:viewCont]; [viewCont release]; viewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; [array addObject:viewCont]; [viewCont release]; [splitViewController setViewControllers:array]; [tabArray addObject:splitViewController]; [splitViewController release]; array = [NSMutableArray array]; splitViewController = [[UISplitViewController alloc] init]; viewCont = [[Master2 alloc] initWithNibName:@"Master2" bundle:nil]; [array addObject:viewCont]; [viewCont release]; viewCont = [[Slave2 alloc] initWithNibName:@"Slave2" bundle:nil]; [array addObject:viewCont]; [viewCont release]; [splitViewController setViewControllers:array]; [tabArray addObject:splitViewController]; [splitViewController release]; // Add the tab bar controller's current view as a subview of the window [tabBarController setViewControllers:tabArray]; [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; return YES; } the class MainViewController is a UIViewController that contains the following method: - (IBAction)push_me:(id)sender { M2 *m2 = [[[M2 alloc] initWithNibName:@"M2" bundle:nil] autorelease]; [self.navigationController pushViewController:m2 animated:YES]; } this method is attached (via interface builder) to a UIButton found within MainViewController.xib Obviously, the method above (push_me) is supposed to create a second UIViewController (called m2) and push m2 into view on the left-side of the split-view when the UIButton is pressed. And yet it does nothing when the button is pressed (even though I can tell that the method is called). Thoughts on where I'm going wrong? TIA!

    Read the article

  • Why does my UIWebView not Allow User Interaction?

    - by thomasmcgee
    Hi, I'm new to these forums so I apologize for my noobieness. I did as thorough a search as I could, but I couldn't find anyone else with this issue, applogise if this has been covered elsewhere. I've created a very simple example of my problem. I'm sure I'm missing something but I can't for the life of me figure out what. I'm creating a UIWebView and adding it to a custom view controller that inherits from UIViewController. When the app loads in the iPad simulator, the uiwebview loads the desired page, but the UIWebView is entirely unresponsive. The webview does not pan or scroll and none of the in page links can be clicked. However, if you change the orientation of the webview suddleny everything works. Thanks in advance for your help!! AppDelegate header #import <UIKit/UIKit.h> #import "EditorViewController.h" @interface FixEditorTestAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; EditorViewController *editorView; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) EditorViewController *editorView; @end AppDelegate Implementation #import "FixEditorTestAppDelegate.h" #import "EditorViewController.h" @implementation FixEditorTestAppDelegate @synthesize window; @synthesize editorView; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSLog(@"application is loading"); editorView = [[EditorViewController alloc] init]; [window addSubview:[editorView view]]; [window makeKeyAndVisible]; return YES; } - (void)dealloc { [window release]; [editorView release]; [super dealloc]; } @end View Controller header #import <UIKit/UIKit.h> @interface EditorViewController : UIViewController <UIWebViewDelegate> { UIWebView *webView; } @property (nonatomic, retain) UIWebView *webView; @end View Controller Implementation #import "EditorViewController.h" @implementation EditorViewController @synthesize webView; /* // 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 loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { NSLog(@"loadView called"); UIView *curView = [[UIView alloc] init]; webView = [[UIWebView alloc] init]; webView.frame = CGRectMake(20, 40, 728, 964); webView.delegate = self; webView.backgroundColor = [UIColor redColor]; [curView addSubview: webView]; self.view = curView; [curView release]; } //Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"viewDidLoad called"); NSURL *url = [[NSURL alloc] initWithString:@"http://www.nytimes.com"]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; [webView loadRequest:request]; [url autorelease]; [request release]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Overriden to allow any orientation. return YES; } - (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 { webView.delegate = nil; [webView release]; [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end

    Read the article

  • UIButton addTarget:action:forControlEvents: results in [NSObject doesNotRecognizeSelector:]

    - by Teodor
    Hi. I tried a lot of stuff, still no result. So I have the following button created programatically in a subclass of UIViewController: rightButton = [UIButton buttonWithType:UIButtonTypeCustom]; rightButton.frame = CGRectMake(0.0, 0.0, 110.0, 40.0); rightButton.titleLabel.font = [UIFont fontWithName:GAME_FONT_NAME_STRING size:20.0]; [rightButton setTitle:@"MyTitle" forState:UIControlStateNormal]; rightButton.backgroundColor = [UIColor clearColor]; [rightButton setTitleColor:[UIColor greenColor] forState:UIControlStateNormal]; [rightButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; [rightButton setBackgroundImage:normalImage forState:UIControlStateNormal]; [rightButton setBackgroundImage:highlightedImage forState:UIControlStateHighlighted]; [rightButton addTarget:self action:@selector(myButton) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:rightButton]; where the selector is: - (void)myButton; I tried everything: - (void)myButton; - (void)myButton:(id)sender; - (void)myButton:(id)sender forEvent:(UIEvent *)event; - (IBAction)myButton; - (IBAction)myButton:(id)sender; - (IBAction)myButton:(id)sender forEvent:(UIEvent *)event; and the corresponding selectors, of course: [rightButton addTarget:self action:@selector(myButton) forControlEvents:UIControlEventTouchUpInside]; [rightButton addTarget:self action:@selector(myButton:) forControlEvents:UIControlEventTouchUpInside]; [rightButton addTarget:self action:@selector(myButton:forEvent:) forControlEvents:UIControlEventTouchUpInside]; [rightButton addTarget:self action:@selector(myButton) forControlEvents:UIControlEventTouchUpInside]; [rightButton addTarget:self action:@selector(myButton:) forControlEvents:UIControlEventTouchUpInside]; [rightButton addTarget:self action:@selector(myButton:forEvent:) forControlEvents:UIControlEventTouchUpInside]; The result is always an uncaught exception - [NSObject doesNotRecognizeSelector:]. However, the usual backtrace of the program is: #0 0x92a6bedb in objc_msgSend () #1 0x03b0a430 in ?? () #2 0x00306b4e in -[UIControl sendAction:to:forEvent:] () #3 0x00308d6f in -[UIControl(Internal) _sendActionsForEvents:withEvent:] () #4 0x00307abb in -[UIControl touchesEnded:withEvent:] () #5 0x002bcddf in -[UIWindow _sendTouchesForEvent:] () #6 0x002a67c8 in -[UIApplication sendEvent:] () #7 0x002ad061 in _UIApplicationHandleEvent () #8 0x02498d59 in PurpleEventCallback () #9 0x01cabb80 in CFRunLoopRunSpecific () #10 0x01caac48 in CFRunLoopRunInMode () #11 0x02497615 in GSEventRunModal () #12 0x024976da in GSEventRun () #13 0x002adfaf in UIApplicationMain () So what is the problem with that button? PS: I am using the iPhone SDK 3.1.3 Update! The following code in the AppDelegate (no declarations in the interface): - (void)applicationDidFinishLaunching:(UIApplication *)application { UIButton *test = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 100.0)]; [test setTitle:@"Title" forState:UIControlStateNormal]; UIImage *bg = [UIImage imageNamed:...]; [test setBackgroundImage:bg forState:UIControlStateNormal]; [test addTarget:self action:@selector(testAction) forControlEvents:UIControlEventTouchUpInside]; [window addSubview:test]; [test release]; [window makeKeyAndVisible]; } - (void)testAction { NSLog(@"Write something..."); } works perfectly! But if I create an empty UIViewController with the same code: - (void)viewDidLoad { UIButton *test = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 100.0)]; [test setTitle:@"Title" forState:UIControlStateNormal]; UIImage *bg = [UIImage imageNamed:...]; [test setBackgroundImage:bg forState:UIControlStateNormal]; [test addTarget:self action:@selector(testAction) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:test]; [test release]; [window makeKeyAndVisible]; } - (void)testAction { NSLog(@"Write something..."); } I get this mysterious error. :-( Help!

    Read the article

  • How do I center a UIImageView within a full-screen UIScrollView?

    - by Sebastian Celis
    In my application, I would like to present the user with a full-screen photo viewer much like the one used in the Photos app. This is just for a single photo and as such should be quite simple. I just want the user to be able to view this one photo with the ability to zoom and pan. I have most of it working. And, if I do not center my UIImageView, everything behaves perfectly. However, I really want the UIImageView to be centered on the screen when the image is sufficiently zoomed out. I do not want it stuck to the top-left corner of the scroll view. Once I attempt to center this view, my vertical scrollable area appears to be greater than it should be. As such, once I zoom in a little, I am able to scroll about 100 pixels past the top of the image. What am I doing wrong? @interface MyPhotoViewController : UIViewController <UIScrollViewDelegate> { UIImage* photo; UIImageView *imageView; } - (id)initWithPhoto:(UIImage *)aPhoto; @end @implementation MyPhotoViewController - (id)initWithPhoto:(UIImage *)aPhoto { if (self = [super init]) { photo = [aPhoto retain]; // Some 3.0 SDK code here to ensure this view has a full-screen // layout. } return self; } - (void)dealloc { [photo release]; [imageView release]; [super dealloc]; } - (void)loadView { // Set the main view of this UIViewController to be a UIScrollView. UIScrollView *scrollView = [[UIScrollView alloc] init]; [self setView:scrollView]; [scrollView release]; } - (void)viewDidLoad { [super viewDidLoad]; // Initialize the scroll view. CGSize photoSize = [photo size]; UIScrollView *scrollView = (UIScrollView *)[self view]; [scrollView setDelegate:self]; [scrollView setBackgroundColor:[UIColor blackColor]]; // Create the image view. We push the origin to (0, -44) to ensure // that this view displays behind the navigation bar. imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, -44.0, photoSize.width, photoSize.height)]; [imageView setImage:photo]; [scrollView addSubview:imageView]; // Configure zooming. CGSize screenSize = [[UIScreen mainScreen] bounds].size; CGFloat widthRatio = screenSize.width / photoSize.width; CGFloat heightRatio = screenSize.height / photoSize.height; CGFloat initialZoom = (widthRatio > heightRatio) ? heightRatio : widthRatio; [scrollView setMaximumZoomScale:3.0]; [scrollView setMinimumZoomScale:initialZoom]; [scrollView setZoomScale:initialZoom]; [scrollView setBouncesZoom:YES]; [scrollView setContentSize:CGSizeMake(photoSize.width * initialZoom, photoSize.height * initialZoom)]; // Center the photo. Again we push the center point up by 44 pixels // to account for the translucent navigation bar. CGPoint scrollCenter = [scrollView center]; [imageView setCenter:CGPointMake(scrollCenter.x, scrollCenter.y - 44.0)]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[[self navigationController] navigationBar] setBarStyle:UIBarStyleBlackTranslucent]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[[self navigationController] navigationBar] setBarStyle:UIBarStyleDefault]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return imageView; } @end

    Read the article

  • How we should load the MFMailViewController in cocos2d ?

    - by srikanth rongali
    I am writing an app in using cocos2d. This method I have written for the selector goToFirstScreen: . The view is in landscape mode. I need to send an email. So, I need to launch the MFMailComposeViewController. I need it in portrait mode. But, the control is not entering in to viewDidLoad of the mailMe class. The problem is in goToScreen: method. But, I do not get where I am wrong ? -(void)goToFirstScreen:(id)sender { NSLog(@"goToFirstScreen: "); CCScene *Scene = [CCScene node]; CCLayer *Layer = [mailME node]; [Scene addChild:Layer]; [[CCDirector sharedDirector] setAnimationInterval:1.0/60]; [[CCDirector sharedDirector] pushScene: Scene]; } This is my mailMe class to launch mail controller #import <UIKit/UIKit.h> #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> #import "cocos2d.h" @interface mailME : CCLayer <MFMailComposeViewControllerDelegate> { UIViewController *mailComposer; } -(void)displayComposerSheet; -(void)launchMailAppOnDevice; @end #import "mailME.h" @implementation mailME -(void)viewDidLoad { NSLog(@"Enetrd in to mail"); Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); if (mailClass != nil) { if ([mailClass canSendMail]) { [self displayComposerSheet]; } else { [self launchMailAppOnDevice]; } } else { [self launchMailAppOnDevice]; } } -(void)displayComposerSheet { CCDirector *director = [CCDirector sharedDirector]; [director pause]; [director stopAnimation]; [director.openGLView setUserInteractionEnabled:NO]; mailComposer = [[UIViewController alloc] init]; [mailComposer setView:[[CCDirector sharedDirector]openGLView]]; [mailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Hello!"]; NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; [picker setToRecipients:toRecipients]; NSString *emailBody = @"It is not working!"; [picker setMessageBody:emailBody isHTML:YES]; [mailComposer presentModalViewController:picker animated:NO]; [picker release]; } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { switch (result) { case MFMailComposeResultCancelled: break; case MFMailComposeResultSaved: break; case MFMailComposeResultSent: break; case MFMailComposeResultFailed: break; default: break; } [mailComposer dismissModalViewControllerAnimated:NO]; [[UIApplication sharedApplication] setStatusBarOrientation:CCDeviceOrientationLandscapeLeft animated:NO]; CCDirector *director = [CCDirector sharedDirector]; [director.openGLView setUserInteractionEnabled:YES]; [director startAnimation]; [director resume]; [mailComposer.view.superview removeFromSuperview]; } -(void)launchMailAppOnDevice { NSString *recipients = @"mailto:[email protected]?&subject=Hello!"; NSString *body = @"&body=It is not working"; NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body]; email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]]; } - (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

  • iPhone Memory Error - when using Build & Debug, How to debug?

    - by LonH99
    I'm a newbie and need some help with an iPhone App running on the Simulator. The app works fine running with Build & Run or Build & Run - breakpoints off, but blows when running with Build & Debug - Breakpoints on. Any help or thoughts would be greatly appreciated. Lon Specifics: No breakpoints set, never gets to any visible simulator results, seems to blow during initialization phase before it can generate any output. Source of app is the DrinkMixer example, in the "Head First iPhone development" book (example built up to page 280) by Dan & Tracey Pilone. Blows With this Error Message: Attaching to process 970. Pending breakpoint 1 - "*0x01c1b001" resolved Program received signal: “EXC_BAD_ACCESS”. No memory available to program now: unsafe to call malloc Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.) No memory available to program now: unsafe to call malloc --- Leaks: The only object noted as "leaked Object" is: Leaked Object # Address Size Responsible Library Responsible Frame Malloc 128 Bytes <blank> 0x3c11950 128Bytes CoreGraphics open_handle_to_dylib_path ___ Object Allocations shows (Highest at top = CFString): Category --- Overall Bytes -- #Overall -- Live Bytes -- #Living * All Allocations * 497kb #5888 496kb #5878 10 CFString 42kb #1126 42kb Malloc 32.00 KB 32kb #1 32kb Malloc 1.00 KB 29kb #29 29kb Malloc 8.00 KB 24kb #3 24kb Malloc 32 Bytes 20.81kb #666 20.75kb Malloc 1.50 KB 19.5kb #13 19.5kb CFDictionary (key-store) 17.64kb #159 17.64kb (note: Except for "All Allocations, the #Living is the same as #Overall) --- List of Calls from Debugger: #0 0x01c1b010 in CFStringCreateByCombiningStrings #1 0x023a0779 in LoadFontPathCache #2 0x023a096b in Initialize #3 0x023a0f3e in GSFontCreateWithName #4 0x003d4575 in +[UIFont boldSystemFontOfSize:] #5 0x002cddaa in +[UINavigationButton defaultFont] #6 0x002d9e37 in -[UINavigationButton initWithValue:width:style:barStyle:possibleTitles:tintColor:] #7 0x002cdc75 in -[UINavigationButton initWithImage:width:style:] #8 0x00468eeb in -[UIBarButtonItem(Static) createViewForNavigationItem:] #9 0x002d1b56 in -[UINavigationItem customRightView] #10 0x002d20e3 in -[UINavigationItem updateNavigationBarButtonsAnimated:] #11 0x002d1e1a in -[UINavigationItem setRightBarButtonItem:] #12 0x00002e7b in -[RootViewController viewDidLoad] at RootViewController.m:41 #13 0x00313796 in -[UIViewController view] #14 0x00311d92 in -[UIViewController contentScrollView] #15 0x0031c2b4 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] #16 0x0031b32e in -[UINavigationController _layoutViewController:] #17 0x0031cd1a in -[UINavigationController _startTransition:fromViewController:toViewController:] #18 0x0031831a in -[UINavigationController _startDeferredTransitionIfNeeded] #19 0x004362e4 in -[UILayoutContainerView layoutSubviews] #20 0x035342b0 in -[CALayer layoutSublayers] #21 0x0353406f in CALayerLayoutIfNeeded #22 0x035338c6 in CA::Context::commit_transaction #23 0x0353353a in CA::Transaction::commit #24 0x00295ef9 in -[UIApplication _reportAppLaunchFinished] #25 0x0029bb88 in -[UIApplication handleEvent:withNewEvent:] #26 0x002976d3 in -[UIApplication sendEvent:] #27 0x0029e0b5 in _UIApplicationHandleEvent #28 0x023a3ed1 in PurpleEventCallback #29 0x01bb6b80 in CFRunLoopRunSpecific #30 0x01bb5c48 in CFRunLoopRunInMode #31 0x00295e69 in -[UIApplication _run] #32 0x0029f003 in UIApplicationMain #33 0x00002ba0 in main at main.m:14 The code, including line #41 (noted below) is as follows. And thanks for the formatting help and comment: import "RootViewController.h" import "DrinkDetailViewController.h"; import "DrinkConstants.h" import "AddDrinkViewController.h" @implementation RootViewController @synthesize drinks, addButtonItem; - (void)viewDidLoad { [super viewDidLoad]; // add PATH for PLIST NSString *path = [[NSBundle mainBundle] pathForResource: @"DrinkDirections" ofType:@"plist"]; NSMutableArray *tmpArray = [[NSMutableArray alloc] initWithContentsOfFile:path]; self.drinks = tmpArray; [tmpArray release]; // Next is Line #41 - I removed earlier empty lines & Comments self.navigationItem.rightBarButtonItem = self.addButtonItem; } - (IBAction) addButtonPressed: (id) sender { NSLog(@"Add button pressed!");

    Read the article

  • I'm trying to pass a string from my first ViewController to my second ViewController but it returns NULL

    - by Dashony
    In my first view controller I have 3 input fields each of them take the user input into and saves it into a string such as: address, username and password as NSUserDefaults. This part works fine. In my second view controller I'm trying to take the 3 strings from first controller (address, username and password) create a html link based on the 3 strings. I've tried many ways to access the 3 strings with no luck, the result I get is NULL. Here is my code: //.h file - first view controller with the 3 input fields CamSetup.h #import <UIKit/UIKit.h> @interface CamSetup : UIViewController <UITextFieldDelegate> { NSString * address; NSString * username; NSString * password; IBOutlet UITextField * addressField; IBOutlet UITextField * usernameField; IBOutlet UITextField * passwordField; } -(IBAction) saveAddress: (id) sender; -(IBAction) saveUsername: (id) sender; -(IBAction) savePassword: (id) sender; @property(nonatomic, retain) UITextField *addressField; @property(nonatomic, retain) UITextField *usernameField; @property(nonatomic, retain) UITextField *passwordField; @property(nonatomic, retain) NSString *address; @property(nonatomic, retain) NSString *username; @property(nonatomic, retain) NSString *password; @end //.m file - first view controller CamSetup.m #import "CamSetup.h" @interface CamSetup () @end @implementation CamSetup @synthesize addressField, usernameField, passwordField, address, username, password; -(IBAction) saveAddress: (id) sender { address = [[NSString alloc] initWithFormat:addressField.text]; [addressField setText:address]; NSUserDefaults *stringDefaultAddress = [NSUserDefaults standardUserDefaults]; [stringDefaultAddress setObject:address forKey:@"stringKey1"]; NSLog(@"String [%@]", address); } -(IBAction) saveUsername: (id) sender { username = [[NSString alloc] initWithFormat:usernameField.text]; [usernameField setText:username]; NSUserDefaults *stringDefaultUsername = [NSUserDefaults standardUserDefaults]; [stringDefaultUsername setObject:username forKey:@"stringKey2"]; NSLog(@"String [%@]", username); } -(IBAction) savePassword: (id) sender { password = [[NSString alloc] initWithFormat:passwordField.text]; [passwordField setText:password]; NSUserDefaults *stringDefaultPassword = [NSUserDefaults standardUserDefaults]; [stringDefaultPassword setObject:password forKey:@"stringKey3"]; NSLog(@"String [%@]", password); } - (void)viewDidLoad { [addressField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey1"]]; [usernameField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey2"]]; [passwordField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey3"]]; [super viewDidLoad]; } @end //.h second view controller LiveView.h #import <UIKit/UIKit.h> #import "CamSetup.h" @interface LiveView : UIViewController { NSString *theAddress; NSString *theUsername; NSString *thePassword; CamSetup *camsetup; //here is an instance of the first class } @property (nonatomic, retain) NSString *theAddress; @property (nonatomic, retain) NSString *theUsername; @property (nonatomic, retain) NSString *thePassword; @end //.m second view LiveView.m file #import "LiveView.h" @interface LiveView () @end @implementation LiveView @synthesize theAddress, theUsername, thePassword; - (void)viewDidLoad { [super viewDidLoad]; theUsername = camsetup.username; //this is probably not right? NSLog(@"String [%@]", theUsername); //resut here is NULL NSLog(@"String [%@]", camsetup.username); //and here NULL as well } @end

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >