Search Results

Search found 369 results on 15 pages for 'subview'.

Page 13/15 | < Previous Page | 9 10 11 12 13 14 15  | Next Page >

  • Problem in Autoresizing subviews in iPhone programmatically

    - by Cathy
    Hi, I have created a UIViewController and a UIView with two UIButtons in it. self.view = [[UIView alloc]initWithFrame:CGRectMake( 0,0,320,480)]; self.view.autoresizesSubviews = YES; self.view.backgroundColor = [UIColor redColor]; UIView *view; view = [[UIVew alloc]initWithFrame:CGRectMake(0,0,320,480)]; view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; UIButton *button1; button.frame = CGRectMake(100,130,120,50); [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [view addSubview:button]; [controller addSubview:view]; -(void)buttonAction:(id)sender { //I have created another view for a purpose [view removeFromSuperview]; UIView *view_obj; **view_obj.backgroundColor = [UIColor greenColor];** view_obj.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth; [self.view addSubview:view_obj]; } Problem: When I change the orientation into landscape the view which has the button is resized but when i click on the button the view with the blueColor is displayed without autoresized. Where i can see half as root view in redColor and half as the subview in greenColor.I have also overrided the ShouldAutoRotate method and done this project programmatically. Please do reply me.

    Read the article

  • Cocos2D Director Pause/Resume Issue

    - by Aditya
    I am trying to play a .gif animation in cocos2D. For this i am using the library glgif. Now, to display the animation i am pausing the Director, adding a subview to show the animation and after the animation is done i am resuming the Director. However, I am not able to resume the state of the Director and it shows blank. So I tried this without pausing and resuming this Director and it still did not work.I also tried detaching the director before tha animation and adding it back afterwards and even that did not work. So is there a way to pause/suspend the Director in the application and properly restore is back? Thanks. Code sample: [[Director sharedDirector] pause]; [[Director sharedDirector] detach]; AppDelegate *del = [[UIApplication sharedApplication] delegate]; [del.window addSubview:del.viewController.view]; [del.window makeKeyAndVisible]; // this is code to call glgif class and start anim. //code to resume the director AppDelegate *del = [[UIApplication sharedApplication] delegate]; [[Director sharedDirector] resume]; [[Director sharedDirector] attachInView:del.window]; MScene *m = [MScene node]; [[Director sharedDirector] replaceScene:m];

    Read the article

  • How do I keep a CALayer, sublayer of a CATiledLayer, from changing it's scale after a zoom ?

    - by David
    I have a CATiledLayer that is used to display a PDF page (this CATiledLayer is the layer type of my UIView which is a subview of a UIScrollView). I want to add overlay markers on this page. So I add a sublayer to my CATiledLayer. This sublayer again hosts the different marker's layers and acts as a grouping layer. So graphically, I have: (keep in mind that I have multiple markers which are CALayers also, this is ascii art after all) pdf page (CATiledLayer) ---------------------- | CALayer | | +---------+ | | | +----+ | | | | |mker| | | | | +----+ | | | +---------+ | | | ---------------------- I have set up the canonical drawLayer:inContext: in my view for drawing the pdf. When I zoom to have more detail, the pdf gets rendered correctly, but the markers get scaled. No matter what I do to the bounds of the CALayer, my markers always become bigger and appear jagged. I would like to have the markers always the same size, as when they were initialized and first shown when the view was drawn. Is this possible ? or am I using a wrong approach ? Should I do special drawing for my contained CALayer in the drawLAyer:inContext: message ? As you see, there are things that I am missing to resolve my problem. Thank you for any help you provide.

    Read the article

  • Changing UITableViewCell textLabel background color to clear

    - by SorinA.
    In my app i have a table view with customViewCells. i subclassed the UITableViewCell class and added an image that will load async and for the text i use cell.textLabel.text = @"someThext". for the cells the background color is set alternatively to [UIColor darkGrayColor] and whitecolor. When i run the app in the simulator and on the pone the textLabel of the cell has the background white. I want to set it to be clear, because i want the background color of the cell to be full not a strip then white then another strip. in the init method of my custom cell i added hoping that the white will turn into red but it doesn't have any effect. [self.textLabel setBackgroundColor:[UIColor redColor]]; i tried also self.textLabel.backgroundColor = [UIColor redColor]; but this also didn't work...if i add a UILabel as a subview the background color of the label can be set..but i don't want to do that because when i rotate the phone i want my labels to auto enlarge... any ideas why setting the background color of cell.textLabel doesn't work? thank you

    Read the article

  • AdMob ad in iPhone app makes App content disappear when "done" is pressed!

    - by nephilite
    Hello All, When I return from an adMob ad by hitting "done" the content of my app has disappeared ! All that remains is a background image I had attached directly to the main window. Oddly I can still hear the result of my touch events from my main screen (which is now gone). This may be related to the issue some people have had regarding a 20 pixel move involving the toolbar...I see something to that effect as the ad starts to overlay. I have admob in another app that is working fine, and I notice when the ad opens in that app the ad content fills the whole screen EXCEPT the top toolbar (it starts right under it). In the new app I'm working on right now this isn't the case. When the ad starts to open I see the tool bar vanish, then the add comes in and fills the entire screen (including the area where the tool bar was); then when I click done and the the ad goes away everything under it is gone as well. It may be worth noting that the App I had working was 2.x and the current app is 3.x (and thus using the admob 3.0 libraries). This is very odd and deal-breaking; I need help ASAP The relevant part of my view hierarchy is as follows: AppDelegate - ViewController - MainView (Ad is in here) There are also some other Views that are children of the ViewController and a UITabbar is also a subview of the ViewController (programmatically declared, not a UITabBar Controller). Any help you can offer would be extremely appreciate...I need to resolve this issue ASAP, release in two days! Thanks!!

    Read the article

  • Custom view in iPhone SDK gets placed incorrectly in realation to statusbar

    - by markqvist
    (ragh, i'm apparently not allowed to post images, so i have included links to the images in this post instead of embedding them) Im writing an iPhone application based on the navigation controller template, but I am not loading the actual navigation controller as the first view in the window. I create a new view controller from a xib, and then add that as a subview, and then only push the navigation view as a modal when i need it. Here's my application: didFinishLaunching ... method in the application deleate RootViewController *rootViewController = (RootViewController *)[navigationController topViewController]; rootViewController.managedObjectContext = self.managedObjectContext; mainViewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:[NSBundle mainBundle]]; mainViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [window addSubview:[mainViewController view]]; [[mainViewController view] setNeedsLayout]; [window makeKeyAndVisible]; return YES; It works but the view is not properly aligned with the statusbar: http://img.exdev.dk/1.png When i click "my ambiances" and push the navigation controller view, and then dismiss it again, the layout is fine: same link as above, just replace the 1 with a 2. Sorry for the hassle, apparently I can also only post one link.... Here's the code I use for presenting/dismissing the navigationcontroller: -(void)pushMyAmbiences { [mainViewController presentModalViewController:navigationController animated:TRUE]; } -(void)returnToMainView { [mainViewController dismissModalViewControllerAnimated:TRUE]; } Is there anything I'm missing here? Layout-wise? Something that needs to be set in the xib? In a vain attempt I tried calling setNeedsLayout on the view, no luck. Any help is greatly appreciated!

    Read the article

  • UIScrollview calling superviews layoutSubviews when scrolling?

    - by marchinram
    Hello, I added a UITableView as a subview to a custom UIView class I'm working on. However I noticed that whenever I scroll the table it calls my classes layoutSubviews. I'm pretty sure its the UIScrollview that the table is inheriting from which is actually doing this but wanted to know if there is a way to disable this functionality and if not why is it happening? I don't understand why when you scroll a scrollview it needs its superview to layout its subviews. Code: @implementation CustomView - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { self.clipsToBounds = YES; UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 15.0, 436.0, 132.0) style:UITableViewStylePlain]; tableView.dataSource = self; tableView.delegate = self; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; tableView.backgroundColor = [UIColor clearColor]; tableView.showsVerticalScrollIndicator = NO; tableView.contentInset = UIEdgeInsetsMake(kRowHeight, 0.0, kRowHeight, 0.0); tableView.tag = componentIndex; [self addSubview:tableView]; [tableView release]; } return self; } - (void)layoutSubviews { // This is called everytime I scroll the tableview } @end

    Read the article

  • How to add a scrollable NSTableView programmatically

    - by Jakob Dam Jensen
    I'm trying to add a tableview to a view in code instead of using Interface Builder and unfortunately it's causing some problems =( Here's an example of how I'm doing it now. NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:someRect]; NSTableView *tableView = [[NSTableView alloc] initWithFrame: scrollView.bounds]; resultsTableView.dataSource = self; resultsScrollView.documentView = resultsTableView; [someView addSubview: scrollView]; So basically I'm just putting the tableView inside the scrollView (because that's what IB is doing) and then adding the latter as a subview of the someView. The result is that a tableView appears - but the no data is shown within the tableView. Debugging shows that the dataSource is being asked for how many rows are in the tableView but the method: tableView:objectValueForTableColumn:row: is never being called. I suspect that this is because of my way of creating the tableView. I've tried google but no luck and the "Introduction to Table Views Programming Guide" on macdevcenter wasn't helpful either. What am I missing? Thanks in advance...

    Read the article

  • Problem with NSUserDefaults and deallocated Instance

    - by Peter A
    Hi, I'm having a problem with NSUserDefaults. I've followed the steps in the books as closely as I can for my app, but still get the same problem. I am getting a *** -[NSUserDefaults integerForKey:]: message sent to deallocated instance 0x3b375a0 error when I try and load in the settings. Here is the code that I have, it is in the App Delegate class. - (void)applicationDidFinishLaunching:(UIApplication *)application { recordingController = [[RecordingTableViewController alloc] initWithStyle:UITableViewStylePlain]; [recordingController retain]; // Add the tab bar controller's current view as a subview of the window [window addSubview:tabBarController.view]; [self loadSettings]; } -(void)loadSettings { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSNumber loop = [defaults objectForKey:@"loop_preference"]; NSNumber play = [defaults objectForKey:@"play_me_preference"]; NSNumber volume = [defaults objectForKey:@"volume_preference"]; } As you can see I am not trying to do anything with the values yet, but I get the error on the line reading in the loop preference. I also get it if I try and read an NSString. Any suggestions would be greatly appreciated. Thanks Peter

    Read the article

  • Clear UITextField when standard number pad is pressed

    - by Manu
    Hi all, I'm sorry if I didn't explain my problem well enough in the title. In my application, I'm using a small subview to create a very basic calculator on the top side of the screen (I just have an UITextField to show the operations and two buttons). Instead of using a custom keyboard for it, I want to use the standard iPhone number pad. My problem is that after doing an operation (e.g. adding two numbers) and showing the result, I cannot figure out how to clear the screen when the user enters a new number. So, for example: User enters "6" - Number 6 is shown in UITextField User selects "+" - UITextField is cleared to make room for the next number User enters "10" - Number 10 is shown in UITextField User selects "+" - 16 is shown as the result of the previous operation, and should stay there until another number is pressed (he wants to continue adding more numbers) User enters "5" At this point, if I was using a custom keyboard, I could clear the UITextField as soon as the button "5" is pressed by the user, but I cannot figure out how to do so when using the standard number pad. So, the result I get at the moment is "165". Is there a way to detect when a key is pressed in the standard number pad so that I can clear the UITextField before the new number appears? I thought there may be a NSNotification for that, but I couldn't find it. I'm aware that I could solve my problem if I created a custom keyboard or if I used two separated UITextFields (one for the operations and another one for the total), but I would like to use the standard number pad if it's possible. Thanks very much!

    Read the article

  • iPhone - UIViewController not rotating when device orientation changes

    - by Ryu
    I have got my own custom UIViewController, which contains a UIScrollView with an UIImageView as it's subview. I would like to make the image to auto rotate when device orientation changes, but it doesn't seem to be working... In the header file, I've got; @interface MyViewController : UIViewController <UIScrollViewDelegate> { IBOutlet UIScrollView *containerView; UIImageView *imageView; } These components are initialised in the loadView function as below; containerView = [[UIScrollView alloc] initWithFrame:frame]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://..."]]; UIImage *image = [[UIImage alloc] initWithData:data]; imageView = [[UIImageView alloc] initWithImage:image]; [image release]; [containerView addSubview:imageView]; And I have added the following method, assuming that's all I need to make the view auto-rotate... -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } MyViewController loads fine with the image I've specified to grab from the URL, and the shouldAutorotate... function is being called, with the correct UIInterfaceOrientation, when I flip the device too. However, didRotateFromInterfaceOrientation method do not get called, and the image doesn't seem to rotate itself... Could someone please point out what I need to add, or what I have done wrong here? Thanks in advance!

    Read the article

  • UINavigationController flashes white when I add it to a superview

    - by Chris Stamper
    Hey guys, I'm adding a NavigationController as a subview of my main view, with the flip animation (like a utility app/flipview thing). Here's how I'm doing it: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:.7]; [UIView setAnimationTransition:([self.tableController.view superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:self.tableHostView cache:YES]; [self.tableController.view removeFromSuperview]; settingsView* backView1 = [[settingsView alloc] initWithNibName:@"settingsView" bundle:nil]; backView1.delegate = self; UINavigationController* settingsNavStack = [[UINavigationController alloc]initWithRootViewController:backView1]; [backView1 release]; settingsNavStack.view.frame = CGRectMake(0, 0, 320, 460); settingsNavStack.navigationItem.title = @"Settings"; [self setBackView:settingsNavStack]; [settingsNavStack release]; [self.tableHostView addSubview:self.backView.view]; [[self backView]setDelegate: self]; When it loads, the view comes in very nicely. However, the navigation bar stays white until like .2 secs after the animation finishes. Anyone know why the navigation bar wouldn't display right away?

    Read the article

  • Removing a view from it's superview causes memory error - why?

    - by mystify
    Xcode is throwing an error at me: malloc: * error for object 0x103f000: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug I tracked down the code until a line where I do this: - (void)inputValueCommitted:(NSString *)animationID finished:(BOOL)finished context:(void *)context { // retainCount of myView is 2! (one for the retain-property, one for beeing a subview) [self.myView removeFromSuperview]; // ERROR-LINE !! self.myView = nil; } When I remove that errorful line, the error is gone. So in conclusion: I can't get rid of my view! It's an UIImageView with nothing else inside, just showing an image. What I do is this: I create an UIView Animation Block, create that UIImageView, assign it to an retain-property with self.myView = ..., and after the animation is done, I just want to get rid of that view. So I remove it from it's superview and then set my property to nil, which lets it go away - in theory. Did anyone else encounter such issues? iPhone SDK 3.0.

    Read the article

  • UIView animation only animating some of the things I ask it to

    - by Ben
    I have a series of (say) boxes on the screen in a row, all subviews of my main view. Each is a UIView. I want to shift them all left and have a new view also enter the screen from the right in lockstep. Here's what I'm doing: // First add a dummy view offscreen UIView * stagingView = /* make this view, which sets up its width/height */ CGRect frame = [stagingView frame]; frame.origin.x = /* just off the right side of the screen */; [stagingView setFrame:frame]; [self stagingView]; And then I set up animations in one block for all of my subviews (which includes the one I just added): [UIView beginAnimations:@"shiftLeft" context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(_animationDidStop:context:)]; [UIView setAnimationDuration:0.3]; for (UIView * view in [self subviews]) { CGRect frame = [view frame]; frame.origin.x -= (frame.size.width + viewPadding); [view setFrame:frame]; } [UIView commitAnimations]; Here's what I expect: The (three) views already on screen get shifted left and the newly staged view marches in from the right at the same time. Here's what happens: The newly staged view animates in exactly as expected, and the views already on the screen do not appear to move at all! (Or possibly they jump without animation to their end locations). And! If I comment out the whole business of creating the new subview offscreen... the ones onscreen do animate correctly! Huh? (Thanks!)

    Read the article

  • How to get a UIScrollView embedded within a UITableCellView to scroll?

    - by Zan
    I have a scroll view containing several images embedded within a custom cell view, it sometimes scrolls horizontally if I keep holding the cell for a while. I tried a lot of things and it doesn't seem to work, please help? Here's part of the CustomCell : UITableViewCell code: -(void) layoutSubviews { CGRect scrollViewFrame = CGRectMake(0, 0, 320, 200); self.scrollView.frame = scrollViewFrame; self.scrollView.backgroundColor = [UIColor whiteColor]; self.scrollView.contentSize = CGSizeMake((320*3), 200); self.scrollView.scrollEnabled = YES; self.scrollView.clipsToBounds = YES; self.scrollView.pagingEnabled = YES; self.scrollView.showsHorizontalScrollIndicator = NO; self.scrollView.showsVerticalScrollIndicator = NO; self.scrollView.scrollsToTop = NO; self.scrollView.delegate = self; self.scrollView.userInteractionEnabled = YES; // add 3 images to subview here pageControl.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7]; pageControl.frame = CGRectMake(0, 170, 320, 30); pageControl.numberOfPages = 8;} I tested the code on a UIViewController and it works just fine, I'm guessing that this is caused by cell selection and I tried returning nil when the cell gets selected and that didn't work. I also tried passing touches to the scrollview and that didn't work either, please help?

    Read the article

  • show UIAlertView when In app purchase is in progress

    - by edie
    Hi... I've added an UIAlertView that has UIActivityIndicatior as a subview on my application. This alertView only show when the purchase is in progress. I've put my alert view in this way in my StoreObserver: - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchasing: [self stillPurchasing]; // this creates an alertView and shows break; case SKPaymentTransactionStatePurchased: [self completeTransaction:transaction]; break; case SKPaymentTransactionStateFailed: [self failedTransaction:transaction]; break; case SKPaymentTransactionStateRestored: [self restoreTransaction:transaction]; break; default: break; } } } - (void) stillPurchasing { UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"In App Purchase" message: @"Processing your purchase..." delegate: nil cancelButtonTitle: nil otherButtonTitles: nil]; self.alertView = alert; [alert release]; UIActivityIndicatorView *ind = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge]; self.indicator = ind; [ind release]; [self.indicator startAnimating]; [self.alertView addSubview: self.indicator]; [self.alertView show]; } When I tap my the buy button this UIAlertView shows together with my UIActivityIndicator.. But when the transaction completes the alertView still on the top of the view and the Indicator was the only one that was removed. My question was how should I release the alertView? Or where/When should I release it. I've added these command to release my alertView and Indicator on these cases: case SKPaymentTransactionStatePurchased: case SKPaymentTransactionStateFailed: case SKPaymentTransactionStateRestored: [self.indicator stopAnimating]; [self.indicator removeFromSuperview]; [self.alertView release]; [self.indicator release]; I've only added the alertView to show that the purchasing was still in progress. Any suggestion to create any feedback to users will be thankful for me.. Thanks

    Read the article

  • About updating a View using in iPhone using Objective C.

    - by Tattat
    I have a scene, called testScene, it works like this: @interface testScene : myScene { IBOutlet UIView *subview; IBOutlet UIView *drawingCanvasView; IBOutlet UIButton *update; } - (void)updateDrawingCanvas: (id) sender; and when the user click the button, update, it will run the updateDrawingCanvas method. So, I have a drawingCanvasView, which gave a drawingCanvas.h, and .m, it like this: #import <UIKit/UIKit.h> @interface DrawingCanvasView : UIView { CGImageRef image; } -(void)setNeedsDisplayInRect:(CGContextRef)context; @end In the DrawingCanvasView, I have a drawRect method like this: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); CGContextMoveToPoint(context, 0.0f, 0.0f); CGContextAddLineToPoint(context, 100.0f, 100.0f); CGContextStrokePath(context); And I want the user click the button, and execute this, so I added a new method called setNeedsDisplayInRect: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, [UIColor yellowColor].CGColor); CGContextMoveToPoint(context, 0.0f, 0.0f); CGContextAddLineToPoint(context, 200.0f, 200.0f); CGContextStrokePath(context); But I can't called that in my updateDrawingCanvas method, it work like this: - (void)updateDrawingCanvas: (id) sender{ NSLog(@"loaded"); [DrawingCanvasView setNeedsDisplayInRect:UIGraphicsGetCurrentContext()]; } It my logic / concept right? or something I did wrong, thx.

    Read the article

  • ScrollView content async downloading problem

    - by Newbee
    Hi! I have UIScrollView with lots of UIImageView inside. In the loadView method I assign some temporary image for each of subview UIImageView images and starts several threads to async download images from internet. Each thread downloads and assign images as follows: NSData *data = [NSData dataWithContentsOfURL:URL]; UIImage *img = [UIImage imageWithData:data]; img_view.image = img; Here is the problem - I expects picture will changed after each image downloaded by I can see only temporary images until all images will downloads. UIScrollView still interact while images downloads - I can scroll temporary images inside it and see scrollers and nothing blocks run loop, but downloaded images doesn't updates.. What I tried to do: Call sleep() in the download thread -- not helps. Call setNeedsDisplay for each ImageView inside ScrollView and for ScrollView -- not helps. What's wrong ? Thanks. Update. I tried some experiments with number of threads and number of images to download. Now I'm sure -- images redraws only when thread finished. For example - if I load 100 images with one thread -- picture updates one time after all images downloads. If I increase number of threads to 10 -- picture updates 10 times -- 10 images appears per update. One more update. I fixed problem by staring new thread from the downloading threads each time one image downloaded and exit current thread (instead of download several images in one thread in the cycle and exit thread only when all downloaded). Obviously it's not a good solution and there must be right approach.

    Read the article

  • ios saving uilabel and uiimageview as uiimage

    - by Ashraf Hussein
    I'm trying to add text to an image bu adding a uilabel as subview to a uiimageview I already did that but I want to save them as an image I'm using render in context but it's not working here's my code UIImage * img = [UIImage imageNamed:@"IMG_1650.JPG"]; float x = (img.size.width/imageView.frame.size.width) * touchPoint.x; float y = (img.size.height/imageView.frame.size.height) * touchPoint.y; CGPoint tpoint = CGPointMake(x, y); UIFont *font = [UIFont boldSystemFontOfSize:30]; context = UIGraphicsGetCurrentContext(); UIGraphicsBeginImageContextWithOptions(img.size, YES, 0.0); [[UIColor redColor] set]; for (UIView * view in [imageView subviews]){ [view removeFromSuperview]; } UILabel * lbl = [[UILabel alloc]init]; [lbl setText:txt]; [lbl setBackgroundColor:[UIColor clearColor]]; CGSize sz = [txt sizeWithFont:lbl.font]; [lbl setFrame:CGRectMake(touchPoint.x, touchPoint.y, sz.width, sz.height)]; lbl.transform = CGAffineTransformMakeRotation( -M_PI/4 ); [imageView addSubview:lbl]; [imageView bringSubviewToFront:lbl]; [imageView setImage:img]; [imageView.layer renderInContext:UIGraphicsGetCurrentContext()]; [lbl.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * nImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(nImg, nil, nil, nil); THX

    Read the article

  • iPhone UIScrollView embedded UIView is clipped

    - by scc
    Hello. I have an iPad UIView subclass (we'll call LargerUIView) with which I do a bunch of drawing via drawRect: once asked. That all appears to be working, and looks the way I like. I'm at the point now of trying to get scrolling working (just in the horizontal to begin), yet when I try to scroll, what shows below is black (ie, appears to have never been drawn). That doesn't surprise me as it's likely been clipped. Looking for suggestions. Here's what I'm doing so far: MyAppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CGRect scrollRect = CGRectMake(0, 0, 768, 1024); UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:scrollRect]; LargerUIView *view = (LargerUIView *)[viewController view]; [scrollView addSubview:view]; [scrollView setContentSize:CGSizeMake(768, pageHeight)]; [scrollView setContentMode:UIViewContentModeRedraw]; [scrollView setClipsToBounds:YES]; [window addSubview:scrollView]; [scrollView release]; // Without this next line, the "frontmost" (ie, most recently added subview) // is the MoxiesAppetizerMenu - which is not equipped to handle scrolling/UIEvents [window sendSubviewToBack:view]; // Show it all. [window makeKeyAndVisible]; return YES; } Any suggestions? Have tried changing "setClipsToBounds" to NO as well.

    Read the article

  • iPhone: Animating a view when another view appears/disappears

    - by MacTouch
    I have the following view hierarchy UITabBarController - UINavigationController - UITableViewController When the table view appears (animated) I create a toolbar and add it as subview of the TabBar at the bottom of the page and let it animate in with the table view. Same procedure in other direction, when the table view disappears. It does not work as expected. The animation duration is OK, but somehow not exact the same as the animation of the table view when it becomes visible When I display the table view for the second time, the toolbar does not disappear at all and remains at the bottom of the parent view. What's wrong with it? - (void)animationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { UIView *toolBar = [[[self tabBarController] view] viewWithTag:1000]; [toolBar removeFromSuperview]; } - (void)viewWillAppear:(BOOL)animated { UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 44, 0); [[self tableView] setContentInset:insets]; [[self tableView] setScrollIndicatorInsets:insets]; // Toolbar initially placed outside of the visible frame (x=320) UIView *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(320, 480-44, 320, 44)]; [toolBar setTag:1000]; [[[self tabBarController] view] addSubview:toolBar]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.35]; [toolBar setFrame:CGRectMake(0, 480-44, 320, 44)]; [UIView commitAnimations]; [toolBar release]; [super viewWillAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { UIView *toolBar = [[[self tabBarController] view] viewWithTag:1000]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.35]; [UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)]; [toolBar setFrame:CGRectMake(320, 480-44, 320, 44)]; [UIView commitAnimations]; [super viewWillDisappear:animated]; }

    Read the article

  • How should child views of UIScrollView report their bounds for contentSize?

    - by Mike
    I'm looking more for advice on the correct design for a view. What I have is a UIScrollView that contains one or more custom Views I have created. My problem is, who reports to the scrollview what it's contentSize should be? I have the following: UIView +-UIScrollView +-CustomView 1 with dynamic height depending on data +-CustomView 2 with dynamic Height depending on data The UIViewController creates new instances of the custom views with data and then adds them as subviews to the UIScrollView. The problem I'm having is how to set the value of the scrollview's contentSize? Right now, I'm not doing that and the contents of the scrollview are clipped with no scrolling possible. Should the custom view call [parent setContentSize:] in its drawRect:? Should the UIViewController query the custom view after creation to get its bounds and then call setContentSize? Should I subclass the UIScrollView to override addSubView to query each subview's height? Is there something else I'm missing? I hope I explained that properly. I'm new to this and still getting a handle on things.

    Read the article

  • The best way to implement drawing features like Keynote

    - by Shamseddine
    Hi all, I'm trying to make a little iPad tool's for drawing simple geometrical objects (rect, rounded rect, ellipse, star, ...). My goal is to make something very close to Keynote (drawing feature), i.e. let the user add a rect (for instance), resizing it and moving it. I want too the user can select many objects and move them together. I've thought about at least 3 differents ways to do that : Extends UIView for each object type, a class for Rect, another for Ellipse, ... With custom drawing method. Then add this view as subview of the global view. Extends CALayer for each object type, a class for Rect, another for Ellipse, ... With custom drawing method. Then add this layer as sublayer of the global view layer's. Extends NSObject for each object type, a class for Rect, another for Ellipse, ... With just a drawing method which will get as argument a CGContext and a Rect and draw directly the form in it. Those methods will be called by the drawing method of the global view. I'm aware that the two first ways come with functions to detect touch on each object, to add easily shadows,... but I'm afraid that they are a little too heavy ? That's why I thought about the last way, which it seems to be straight forward. Which way will be the more efficient ??? Or maybe I didn't thought another way ? Any help will be appreciated ;-) Thanks.

    Read the article

  • MPMoviePlayerView fade in/out of overlay

    - by therobot
    I've got a MPMoviePlayerViewController, and I've added an overlay as a subview to the MPMoviePlayerController.view that it controls. Does anyone know if there's an easy way to make my added overlay fade in and out with the rest of the controls? My code to initialize and present the player is: LandscapeMPVC * theMovieViewController = [[LandscapeMPVC alloc] initWithContentURL:sourceURL]; MPMoviePlayerController * theMoviePlayer = [theMovieViewController moviePlayer]; [theMoviePlayer setRepeatMode:MPMovieRepeatModeOne]; [theMoviePlayer setScalingMode:MPMovieScalingModeAspectFit]; [theMoviePlayer setFullscreen:YES]; // Attemps at overlays MPViewOverlayController * overlayCont = [[MPViewOverlayController alloc] init]; [[theMovieViewController view] addSubview:overlayCont.view]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resetToolbar:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMoviePlayer]; [self presentMoviePlayerViewControllerAnimated:theMovieViewController]; LandscapeMPVC is just a subclass of MoviePlayerViewController where I overwrite the orientation code. When the rest of the controls fade in the movie player, my custom overlay does not. Is there some code in the controller that I need to add, or some notification that is sent? Any input would be greatly appreciated.

    Read the article

  • Memory leak in Apples 'Scrolling' sample code

    - by John
    Hi All, I'm using code based on Apple's "Scrolling" sample code - here's where I have a problem: // load all the images from our bundle and add them to the scroll view NSUInteger i; for (i = 1; i <= jNumImages; i++) { NSString *imageName = [NSString stringWithFormat:@"page%d.png", i]; UIImage *image = [UIImage imageNamed:imageName]; UIImageView *imageView2 = [[UIImageView alloc] initWithImage:image]; The UIImageView causes a leak - it doesn't seem to be releasing (though I do state [imageView2 release]; after adding the imageView as a subView to scrollView2 I have say 15 chapters of a book each held in a nav bar, each containing a scroll view with one chapters worth of these image views (each image is a page). When I get to around the second last chapter the app crashes due to the memory leaks... really annoying! I think it might be because imageView's been alloc'd twice (in alloc and in addSubView) but i'm not sure.... tried releasing twice but it didn't seem to help. any pointers? Thanks in advance ^.^

    Read the article

< Previous Page | 9 10 11 12 13 14 15  | Next Page >