Search Results

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

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

  • Issit possible to load a UIVIewcontroller from uiview of another UIViewController

    - by chako89
    Guys, need your advise here. I have: an UIViewController A UIView B: I added subview which is a UIView to the UIViewController A an UIViewController C What I did is: in UIViewController A's viewDidLoad's method, I call this: UIView *subviewB = [[Subview alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]; [subviewB subviewBMethod]; // [self.view addSubview:rsubviewB]; SubviewBMethod code is to create an view, inside this view have a button. Once this button is clicked, it will change to UIViewController C. I tried this: [self presentModalViewController:self.UIViewControllerC animated:YES]; And I got this error message: warning: incompatible Objective-C types 'struct UIViewControllerC *', expected 'struct UIViewController *' when passing argument 1 of 'presentModalViewController:animated:' from distinct Objective-C type When I run the app, it terminates immediately when I click the button, I opened the console bug, there is no any error message. My method must be wrong, thus my question is: Issit possible to load a UIVIewcontroller from uiview of another UIViewController? If: Yes: How to do it? No: What should I do? THank you =)

    Read the article

  • Does a hidden UIViewController consume any resources (iPhone)?

    - by MrDatabase
    My simple iPhone game has two basic "screens": home screen (UIViewController subclass) game screen (UIWindow w/ EAGLLayer where all the OpenGL drawing happens) Currently when the user taps "Play" on the homescreen the UIViewController is just hidden and the game screen is revealed. When the game is over the homescreen UIViewController is unhidden. Does the hidden UIViewController consume any resources when it's hidden?

    Read the article

  • Custom UIViewController is not responsive to device rotation

    - by Wayne Lo
    I have a custom UIViewController, which is the only subView of UIView. The UIViewController contains delegate function: (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } This function is called once when the application starts and is never called again when the device is rotated. I also notice that the willRotateToInterfaceOrientation function is never called. I pretty much commented out all the content in the UIViewController but it is still not responding to device rotation.

    Read the article

  • Draw a line over UIViewController

    - by ghiboz
    Hi all, I have my app on iPhone with a UIViewController with some stuff inside.. image, textbox, etc... is there a way to draw a line or something like this using opengl directly inside the UIViewController? thanks in advance

    Read the article

  • Sibling UIViewController Navigation

    - by Joo Park
    would anybody care to comment on this piece of code? It allows you to do "prev" or "next" once in the detail view of a uiviewcontroller. So, if you have 4 uiviewcontrollers, you can navigate from #3 to #2 with previous or #3 to #4 with next. It works, but, my question is, is this the best way to implement this? or, is there a better way. http://github.com/joop23/UIViewController

    Read the article

  • Rotate UIViewController to counteract changes in UIInterfaceOrientation

    - by Peter Hajas
    Hi there, I've been searching a lot on this, and can't find anything to help me. I have a UIViewController contained within another UIViewController. When the parent UIViewController rotates, say from Portrait to LandscapeLeft, I want to make it look as though the child didn't rotate. That is to say. I want the child to have the same orientation to the sky regardless of the parent's orientation. If it has a UIButton that's upright in Portrait, I want the right-side of the button to be "up" in UIInterfaceOrientationLandscapeLeft. Is this possible? Currently, I'm doing really gross stuff like this: -(void) rotate:(UIInterfaceOrientation)fromOrientation: toOr:(UIInterfaceOrientation)toOrientation { if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationLandscapeRight)) || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationLandscapeLeft))) { } if(((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown)) || ((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationPortrait))) { } if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationLandscapeLeft)) || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationLandscapeRight))) { } if(((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown)) || ((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationPortrait))) { } if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown)) || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationPortrait))) { } if(((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationLandscapeRight)) || ((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationLandscapeLeft))) { } } which seems like a perfectly good waste of code. Furthermore, I was planning on using CGAffineTransform (like cited here: http://www.crystalminds.nl/?p=1102) but I'm confused about whether I should change the view's dimensions to match what they will be after the rotation. The big nightmare here is that you have to keep track of a global "orientation" variable. If you don't, the illusion is lost and the ViewController is rotated into whatever. I could really use some help on this, thanks!

    Read the article

  • drawRect gets called on UIView subclass but not on UIViewController

    - by HotFudgeSunday
    My code is working so far but I had to create a Class for the UIView. This is a bit inconvenient because I need to interact with the ViewController too. BTW, I did try [self setNeedsDisplay] on the ViewDidLoad of the UIViewController subclass file but it didn't work. Here's the code, which works on UIView Subclass but doesn't get called on a UIViewController one: - (void)drawRect:(CGRect)rect { UIColor *currentColor = [UIColor redColor]; CGContextRef context = UIGraphicsGetCurrentContext(); someNum = 1; CGContextBeginPath(context); CGContextMoveToPoint(context, 30, 40); [self addDotImageX:30 andY:40]; CGContextSetLineWidth(context, 2); CGContextSetStrokeColorWithColor(context, currentColor.CGColor); CGContextStrokePath(context); } Any ideas on what to try? BTW, this is a TabBar App. I know those can somehow block the calls to drawRect. The Tabs where created programatically, not through a Nib. Eg: NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init]; UIViewController *vc; vc = [[Education alloc] init]; vc.title = @"Education"; [listOfViewControllers addObject:vc]; vc.tabBarItem.image = [UIImage imageNamed:@"info.png"]; [vc release]; I would appreciate any ideas. I've been through the answers on this site related to setNeedsDisplay not calling drawRect and haven't found an answer for my particular case. Thanks.

    Read the article

  • Two UIViews, one UIViewController (in one UINavigationController)

    - by jdandrea
    Given an iPhone app with a UITableViewController pushed onto a UINavigationController, I would like to add a right bar button item to toggle between the table view and an "alternate" view of the same data. Let's also say that this other view uses the same data but is not a UITableView. Now, I know variations on this question already exist on Stack Overflow. However, in this case, that alternate view would not be pushed onto the UINavigationController. It would be visually akin to flipping the current UIViewController's table view over and revealing the other view, then being able to flip back. In other words, it's intended to take up a single spot in the UINavigationController hierarchy. Moreover, whatever selection you ultimately make from within either view will push a common UIViewController onto the UINavigationController stack. Still more info: We don't want to use a separate UINavigationController just to handle this pair of views, and we don't want to split these apart via a UITabBarController either. Visually and contextually, the UX is meant to show two sides of the same coin. It's just that those two sides happen to involve their own View Controllers in normal practice. Now … it turns out I have already gone and quickly set this up to see how it might work! However, upon stepping back to examine it, I get the distinct impression that I went about it in a rather non-MVC way, which of course concerns me a bit. Here's what I did at a high level. Right now, I have a UIViewController (not a UITableViewController) that handles all commonalities between the two views, such as fetching the raw data. I also have two NIBs, one for each view, and two UIView objects to go along with them. (One of them is a UITableView, which is a kind of UIView.) I switch between the views using animation (easy enough). Also, in an effort to keep things encapsulated, the now-split-apart UITableView (not the UIViewController!) acts as its own delegate and data source, fetching data from the VC. The VC is set up as a weak, non-retained object in the table view. In parallel, the alternate view gets at the raw data from the VC in the exact same way. So, there are a few things that smell funny here. The weak linking from child to parent, while polite, seems like it might be wrong. Making a UITableView the table's data source and delegate also seems odd to me, thinking that a view controller is where you want to put that per Apple's MVC diagrams. As it stands now, it would appear as if the view knows about the model, which isn't good. Loading up both views in advance also seems odd, because lazy loading is no longer in effect. Losing the benefits of a UITableViewController (like auto-scrolling to cells with text fields) is also a bit frustrating, and I'd rather not reinvent the wheel to work around that as well. Given all of the above, and given we want that "flip effect" in the context of a single spot on a single UINavigationController, and given that both views are two sides of the same coin, is there a better, more obvious way to design this that I'm just happening to miss completely? Clues appreciated!

    Read the article

  • iphone how to remove modal uiviewcontroller from memory

    - by Scott Pendleton
    I have a root UIViewController which has a property called webView. WebView is a UIViewController with a XIB that contains a UIWebView. From my root view I modally (is there any other way?) load the webView ViewController and set its URL, always to the same page. I discovered that if, after loading the webView, I used its default Web page to navigate to another Web page, and then closed the webView and returned to the root controller -- AND THEN reopened the webView, that the webView was not showing the default page but rather the page I navigated to, which means the webView ViewController never got destroyed and removed from memory. This strikes me as very bad. So in the root ViewController, I added this code under viewWillAppear:animated -- if (self.webView != nil) { self.webView = nil) } Is that sufficient? Is there a better way?

    Read the article

  • Adding UIViewController.view to another view causes orientation problems

    - by Bob Vork
    Short version: I'm alloc/init/retaining a new UIViewController in one UIViewControllers viewDidLoad method, adding the new View to self.view. This usually works, but it seems to mess up orientation change handling of my iPad app. Longer version: I'm building a fairly complex iPad application, involving a lot of views and viewcontrollers. After running into some difficulties adjusting to the device orientation, I made a simple XCode project to figure out what the problem is. Firstly, I have read the Apple Docs on this subject (a small document called "Why won't my UIViewController rotate with the device?"), and while I do believe it has something to do with one of the reasons listed there, I'm not really sure how to fix it. In my test project I have an appDelegate, a rootViewController, and a UISplitViewController with two custom viewControllers. I use a button on the rootViewController to switch to the splitViewController, and from there I can use a button to switch back to the rootViewController. So far everything is great, i.e. all views adjust to the device orientation. However, in the right viewController of the splitViewController, I use the viewDidLoad method to initialize some other viewControllers, and add their views to its own view: self.newViewController = [[UIViewController new] autorelease]; [newViewController.view setBackgroundColor:[UIColor yellowColor]]; [self.view addSubview:newViewController.view]; This is where things go wrong. Somehow, after adding this view, adjusting to device orientation is messy. On startup everything is fine, after I switch to the splitViewController everything is still fine, but as soon as I switch back to the rootViewController it's all over. I have tried (almost) everything regarding retaining and releasing the viewcontroller, but nothing seems to fix it. As you can see from the code above, I have declared the newViewController as a property, but the same happens if I don't. Shouldn't I be adding a ViewController's view to my own view at all? That would really mess up my project, as I have a lot of viewControllers doing all sorts of things. Any help on this would be greatly appreciated...

    Read the article

  • How to push UIViewController into UINavigationController from seperate UIView of different UIViewCon

    - by Kundan
    I have a UIViewController(AbcViewController) with NavigationController.AbcViewController uses UIView(AbcView) as its view. AbcView has a UITableView. I have set This TableView's datasource in AbcViewController and delegate in its SuperView i.e. AbcView. How will I push another UIViewController(XyzViewcontroller) into navigationController when I select a row in this table because it gives "error: request for member 'navigationController' in something not a structure or union" when I do this : [self.navigationController pushViewController:xyzViewcontroller animated:TRUE]; I also did this : AbcViewController *parentVC; [parentVC.navigationController pushViewController:xyzViewcontroller animated:TRUE]; Though it builds successfully but XyzViewcontroller's view does not appear. It does not push XyzViewcontroller's view into navigationController. Thanks For Any Help.

    Read the article

  • Rotation of a single UIViewController in a UITabBarController

    - by burki
    Hi! I have a UITabBarController with four UINavigationControllers. Well, I want to enable the rotation just for one of the four UIViewControllers. According to Apple's doc you shouldn't subclass UITabBarController, so I don't wanna do that. All UIViewControllers should support the same orientations that it works, but that's not what I want. How can the single UIViewController, which should support the rotation, detect that the device has changed its orientation? Because unless all the UIViewControllers added to the UITabBarControllers support the same orientation, the methods of the UIViewController for managing the rotation aren't called. I've been searching now for a while, but I haven't already found a pleasant answer. I guess a lot of developers wonder how to manage that. I already thank you for your answer.

    Read the article

  • iPhone - dealloc subview UIViewController when removeFromSuperview

    - by bbullis21
    I have several buttons on my main UIViewController (main menu) that creates and adds a subview UIViewController on top of the main menu. When I remove the subview the memory from that controller is not released. How can I release that subviews memory instantly? Does anyone have an example? This would solve all my problems! Thanks in advance. Here is how I add a subview if((UIButton *) sender == gameClassicBtn) { GameClassic *gameClassicController = [[GameClassic alloc] initWithNibName:@"GameClassic" bundle:nil]; self.gameClassic = gameClassicController; [gameClassicController release]; [self.view insertSubview:gameClassicController.view atIndex:1]; }

    Read the article

  • UINavigationController as child view of UIViewController

    - by Gregg
    I have an application that isn't nav based. So there is no UINavigationController in the App Delegate. However, I need to switch to a UINavigationController for a piece of the application. Steps I currently took... Create a new Class that extends UIViewController Added a UINavigationController via IB Told IB that the new UIViewController's view is the view for the UINavigationController The problem now is that the File's Owner needs it's view set. But via IB there is no way to specify this. So obviously, I'm not going about this the right way. Any tips in the right direction are much appreciated.

    Read the article

  • When my UIViewController accesses an NSArray in my AppDelegate from an IBAction it crashes the progr

    - by JasonClark
    I have a couple UIViewControllers that I am trying to access an array inside my AppDelegate. When I use an IBAction UIButton and in that method I access my AppDelegate my program dies silently. Nothing in output or the debugger, it just stops. If I run it several times I can see that it is failing to access the array properly. To investigate this problem I created a very basic app. In my AppDelegate.h I declared and set properties for the array #import <UIKit/UIKit.h> @class MyViewController; @interface MyAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MyViewController *viewController; NSArray *images; } @property (nonatomic, retain) NSArray *images; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet MyViewController *viewController;` In the AppDelegate.m I synthesised and initialized the NSArray (Also made sure the images were added to the Resources folder). @synthesize images; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { images = [NSArray arrayWithObjects: [[NSBundle mainBundle] pathForResource:@"bamboo_nw" ofType:@"jpg"], ..... nil]; NSLog(@"init images size:%i",[images count]); [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } In my UIViewController.h I added class, imported header file, declared, and set properties for my AppDelegate pointer. #import <UIKit/UIKit.h> #import "MyAppDelegate.h" @class MyAppDelegate; @interface MyViewController : UIViewController { MyAppDelegate *mainDelegate; IBOutlet UIButton mybutton; } @property (nonatomic, retain) MyAppDelegate mainDelegate; @property (nonatomic, retain) UIButton *mybutton; -(IBAction) doSomething;` In my UIViewController.m I synthesize and assign my AppDelegate. I set up an IBAction that will log the same count of the NSArray from the AppDelegate. #import "MyViewController.h" #import "MyAppDelegate.h" @implementation MyViewController @synthesize mybutton; - (void)viewDidLoad { mainDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"vdl images size:%i",[mainDelegate.images count]); [super viewDidLoad]; } -(IBAction) doSomething { NSLog(@"ds images size:%i",[mainDelegate.images count]); } I print the size of the NSArray in the AppDelegate when I create it, in the ViewController when I first assign my AppDelegate pointer, and then as a result of my IBAction. I find that everytime I hit the button the program dies. On the third time I hit the button, I saw that it ran my IBAction but printed my array size as 1 instead of 8. Am I missing something? Also, why don't I get stack traces or anything, the debugger just dies silently? Thanks in advance for any help! Debugger Console output for 3 runs: [Session started at 2010-05-10 06:21:32 -0700.] 2010-05-10 06:21:44.865 My[59695:207] init images size:8 2010-05-10 06:21:47.246 My[59695:207] vdl images size:8 [Session started at 2010-05-10 06:22:15 -0700.] 2010-05-10 06:22:18.920 My[59704:207] init images size:8 2010-05-10 06:22:19.043 My[59704:207] vdl images size:8 [Session started at 2010-05-10 06:22:23 -0700.] 2010-05-10 06:22:25.966 My[59707:207] init images size:8 2010-05-10 06:22:26.017 My[59707:207] vdl images size:8 2010-05-10 06:22:27.814 My[59707:207] ds images size:1

    Read the article

  • UIViewController presentModalViewController: animated: doing nothing?

    - by ryyst
    Hi, I recently started a project, using Apple's Utility Application example project. In the example project, there's an info button that shows an instance of FlipSideView. If you know the Weather.app, you know what the button acts like. I then changed the MainWindow.xib to contain a scrollview in the middle of the window and a page-control view at the bottom of the window (again, like the Weather.app). The scrollview gets filled with instances of MainView. When I then clicked the info button, the FlipSideView would show, but only in the area that was previously filled by the MainView instance – this means that the page-control view on the bottom of the page still showed when the FlipSideView instance got loaded. So, I thought that I would simply add a UIViewController for the top-most window, which is the one declared inside the AppDelegate created along side with the project. So, I created a subclass of UIViewController, put an instance of it inside MainWindow.xib and connected it's view outlet to the UIWindow declared as window inside the app delegate. I also changed the button's action, so that it know sends a message to the MainWindowController instance. The message does get sent (I checked with NSLog() statements), but the FlipSideView doesn't get shown. Here's the relevant (?) code: FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil]; controller.delegate = self; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; [controller release]; Why's this not working? I've uploaded the entire project here for you to be able to see the whole thing. Thanks for help! -- Ry

    Read the article

  • how to set UISwitch pointer to access switch from one uiviewcontroller another uiviewcontroller

    - by Rkm
    System UIViewcontroller has button event.Tap on Button fire InfoTableviewController. InfoTableview has UISwitch . How to set NSMutableArray of UIswitch pointer for System UIViewcontroller to access switch . SystemUIviewcontroller button event - (IBAction) Info_Button_Clicked:(id) sender { // pushcontroller Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:info animated:YES]; [info release]; } Here for Info TableviewController // 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; } }

    Read the article

  • Crash on iOS when system purges memory and closes a UIViewController

    - by Amiramix
    My application is crashing when one of the views is purged from memory because of low-memory condition. At least this is what I understand from the crashlog. It happens on numerous screens but only when opening a Facebook dialog (using the Facebook SDK). Basically, looks like the system sometimes runs out of memory when we need to present a Facebook dialog (e.g. to let user post something on the Facebook timeline). Date/Time: 2012-03-14 19:47:33.819 +0000 OS Version: iPhone OS 5.1 (9B176) Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x30000008 Crashed Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libobjc.A.dylib 0x30f2bf78 objc_msgSend + 16 1 MyApp 0x00003c0e -LTBaseViewController viewDidUnload (LTBaseViewController.m:145) 2 MyApp 0x00004ea2 -LTBaseTableViewController viewDidUnload (LTBaseTableViewController.m:90) 3 UIKit 0x33766bd8 -[UIViewController unloadViewForced:] + 244 4 UIKit 0x338ae492 -[UIViewController purgeMemoryForReason:] + 58 5 Foundation 0x3071a4f8 __57-NSNotificationCenter addObserver:selector:name:object:_block_invoke_0 + 12 6 CoreFoundation 0x30e95540 ___CFXNotificationPost_block_invoke_0 + 64 7 CoreFoundation 0x30e21090 _CFXNotificationPost + 1400 8 Foundation 0x3068e3e4 -NSNotificationCenter postNotificationName:object:userInfo: + 60 9 Foundation 0x3068fc14 -NSNotificationCenter postNotificationName:object: + 24 10 UIKit 0x3387926a -UIApplication _performMemoryWarning + 74 11 UIKit 0x33879364 -UIApplication _receivedMemoryNotification + 168 12 libdispatch.dylib 0x36a12252 _dispatch_source_invoke + 510 13 libdispatch.dylib 0x36a0fb1e _dispatch_queue_invoke$VARIANT$up + 42 14 libdispatch.dylib 0x36a0fe64 _dispatch_main_queue_callback_4CF$VARIANT$up + 152 15 CoreFoundation 0x30e9c2a6 __CFRunLoopRun + 1262 16 CoreFoundation 0x30e1f49e CFRunLoopRunSpecific + 294 17 CoreFoundation 0x30e1f366 CFRunLoopRunInMode + 98 18 GraphicsServices 0x33fb6432 GSEventRunModal + 130 19 UIKit 0x336f5e76 UIApplicationMain + 1074 20 MyApp 0x00004818 main (main.m:16) 21 MyApp 0x000023b4 0x1000 + 5044 I checked and there are almost no memory leaks, e.g. when testing the app for an hour the total memory leaked was around 2-3Kb caused by some string-copying libraries. So I don't believe this is caused by the application. I guess that when the phone is not restarted for some time there are applications running in the background and when using Facebook SDK the memory becomes a problem and the system tries to recover the memory from random applications, including my application. My question is, how can I prevent this crash from happening? How should I handle unloadViewForced on a view controller to make the app more robust in low-memory conditions? And lastly, am I right that this crashlog suggests the crash occurred because the system tried to free memory and my application didn't handle it properly? Any help greatly appreciated.

    Read the article

  • UIViewController memory management

    - by jAmi
    Hi I have a very basic issue of memory management with my UIViewController (or any other object that I create); The problem is that in Instruments my Object allocation graph is always rising even though I am calling release on then assigning them nil. I have 2 UIViewController sub-classes each initializing with a NIB; I add the first ViewController to the main window like [window addSubView:first.view]; Then in my first ViewController nib file I have a Button which loads the second ViewController like : -(IBAction)loadSecondView{ if(second!=nil){ //second is set as an iVar and @property (nonatomic, retain)ViewController2* sceond; [second release]; second=nil; } second=[[ViewController2* second]initWithNibName:@"ViewController2" bundle:nil]; [self.view addSubView:second.view]; } In my (second) ViewController2 i have a button with an action method -(IBAction) removeSecond{ [self.view removeFromSuperView]; } Please let me know if the above scheme works in a managed way for memory...? In Instruments It does not show release of any allocation and keeps the bar status graph keeps on rising.

    Read the article

  • UIViewController remove subview

    - by ghiboz
    Hi all! I add a view as subview of my uiviewcontroller like this: // into my ViewController: UIImageView *imView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.jpg"]]; imView.frame = CGRectMake(2, 46, 1020, 720); [self.view addSubview:imView]; now, with another button I wish remove the imView from the subview chain.. how can I do to do this?? thanks

    Read the article

  • iPhone MailComposer class UIViewController dismissModalViewControllerAnimated issues

    - by Scott Pendleton
    I created a class to launch the MailComposer so that my iPhone app would only have one place to go when generating various kinds of e-mail: some with attachments, some not. Some with pre-filled addresses, some not. I didn't want my class implement UIViewController, but it has to so it can be the delegate for the MailComposer. Otherwise, the view controllers that call my class would themselves have to be delegates for the MailComposer, which defeats the purpose. The downside of having my class be a view controller is that it has to load to the screen before it can modally bring up the MailComposer. Unfortunately, view controllers can't be transparent. The effect is, whatever is on screen gets covered by a solid white view controller for a moment before the MailComposer appears. I could maybe live with that, but not this: after the MailComposer goes away, I'm left with my blank view controller occupying the screen. I ought to be able to get rid of it from within itself by calling this: [self.parentViewController dismissModalViewControllerAnimated:NO]; But that dies a horrible death: "Loading 43365 stack frames..." Has my class -- a UIViewController that pre-fills and then launches a MailComposer -- lost track of its parentViewController? It isn't nil, because I've tested for that. As launched from within the current view controller... // My class is called Email. Email *oEmail = [[[Email alloc] init] retain]; // Red, to remind myself that I'd like to someday learn to make it transparent. oEmail.view.backgroundColor = [UIColor redColor]; // Pre-fill whatever fields you want, and specify attachments. oEmail.EmailSubject = @"I am truly stumped"; // This has to go on screen first. [self presentModalViewController:oEmail animated:NO]; // Then this can happen, which brings up the MailComposer. [oEmail f_SendEmail]; // Commenting out the next line didn't help, so I turned it back on. [oEmail release]; Inside the class, you need the mailComposeController:didFinishWithResult:error: method to make the MailComposer go away, and for that to happen, the class has to be the MFMailComposeViewControllerDelegate. Here's what happens in there: // This gets rid of the mail composer. [self dismissModalViewControllerAnimated:YES]; // This never fails to get rid of other modal view controllers when called // from within those controllers, but boy does it not work here. [self.parentViewController dismissModalViewControllerAnimated:NO]; If you can help me, I will be truly thankful!

    Read the article

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