Search Results

Search found 324 results on 13 pages for 'scrollview'.

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

  • Why won't my CATiledLayer scroll in a UIScrollView after zooming?

    - by Brodie4598
    I'm currently having the following problem with CATiledLayer: when the view first loads, the scrolling works perfectly, but then when you zoom once, the view snaps to the anchor point (top left corner) and it can no longer scroll at all. The zooming works in that it will zoom in and out, but it will only zoom to the top left corner. My code is as follows: #import <QuartzCore/QuartzCore.h> #import "PracticeViewController.h" @implementation practiceViewController //@synthesize image; - (void)viewDidLoad { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, image.size.width, image.size.height); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.anchorPoint = CGPointMake(0.0f, 1.0f); tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1000, 1000); tiledLayer.levelsOfDetail = 6; tiledLayer.levelsOfDetailBias = 0; tiledLayer.bounds = pageRect; tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f); myContentView = [[UIView alloc] initWithFrame:self.view.bounds]; [myContentView.layer addSublayer:tiledLayer]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.minimumZoomScale = .2; scrollView.maximumZoomScale = 1; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height); CGContextDrawImage (ctx, imageRect, [image CGImage]); } @end

    Read the article

  • iphone uiscrollview and uiimageview - setting initial zoom

    - by Brodie4598
    I use the following code to load an image into an scroll view. The image always loads at 100% zoom. Is there a way to set it to load to another zoom level, say .37? UIImageView *tempImage = [[UIImageView alloc]initWithImage:[UIImage imageWithData:data]]; self.imageView = tempImage; scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height); scrollView.maximumZoomScale = 1; scrollView.minimumZoomScale = .37; scrollView.clipsToBounds = YES; scrollView.delegate = self; [scrollView addSubview:imageView];

    Read the article

  • UIScrollView works as expected but scrollRectToVisible: does nothing

    - by mahboudz
    HI. I have used UIScrollView before, and am using it now, and never had a problem. I'm now adding it to an old app, and while it works as expected (I can look at the contents, scroll around with my finger, all the bounds and sizes are setup right so there is no empty space in the content, etc.), I just can't get scrollToRectVisible to work. I have even simplified the call so that it merely moves to the 0,0 position: [scrollView scrollRectToVisible:CGRectMake(0, 0, 10, 10) animated:YES]; or move it to 0,200: [scrollView scrollRectToVisible:CGRectMake(0, 200, 10, 10) animated:YES]; I even made a quick app to test this and I can get scrollRectToVisible to work there as I expect. But in my old app, I can't seem to make it do anything. I can make the scrollView scroll with setContentOffset:, but that's not what I want. This scrollView and its contents are defined in the nib by IB and used with an IBOutlet. The only code I am using in my app to handle the scrollView is [scrollView setContentSize:CGSizeMake(scrollView.contentSize.width, imageView.frame.size.height)]; (I'm only interested in vertical scrolling not horizontal). Has anyone run into a problem like this? I have compared the scrollView attributes in both apps and they are identical. ADDENDUM: My scrollViews frame is: 0.000000 0.000000 480.000000 179.000000 My scrollViews contentSize is: 0.000000 324.000000 It still acts like the rect I want to scroll to is already visible and no scrolling is needed. Not sure if that is what is happening. This is just the darnest thing. Seems like such an easy thing to resolve... ADDENDUM #2: This is how I am making do without scrollRectToVisible: CGPoint point = myRect.origin; if (![clefScrollView pointInside:point withEvent:nil]) { point.x = 0; if (point.y > clefScrollView.contentSize.height - clefScrollView.bounds.size.height) point.y = clefScrollView.contentSize.height - clefScrollView.bounds.size.height; [clefScrollView setContentOffset:point animated: YES]; } Everything else about this scrollView works as expected, but scrollRectToVisible. WHY?!? Any wild guesses?

    Read the article

  • UIViewScrollviw UITableView subview scrolling. IOS

    - by user1484810
    I have a UIScrollview with a UITableview subview. The UIScrollview scrolls the UITableView horizontally. The UITable view naturally scrolls up and down. If a user places their finger on the UitableView, and moves (swipes) horizontally, The delegate method below is invoked (void)scrollViewDidScroll:(UIScrollView *)scrollView with scrollView isEqual theUIScrollView If the user lifts their finger and places it back down on the UITableView and moves in a vertical direction The delegate method below is invoked (void)scrollViewDidScroll:(UIScrollView *)scrollView with scrollView isEqual = theUITable If however the user places their finger and moves in a horizontally (void)scrollViewDidScroll:(UIScrollView *)scrollView with scrollView isEqual theUIScrollView If the user then moves the finger (without lifting it) in a vertical direction. delegate method scrollViewDidScroll is not invoked at all. (The reverse is true too.) I note that the "Pulse News" app seems to behave in the above manner.. Ultimately I want to figure out how to get the UITableView and UIScrollview moving in a "unidirectional" fashion, with one finger kept on the screen. Thanks...

    Read the article

  • iOS iPad Master Detail template can't interact with detail view

    - by CraigularB
    I have an iPad app generated from the Master-Detail template in XCode. The iPad Storyboard has under the Detail View Controller a View that holds a ScrollView which holds an ImageView. In the DetailViewController.m file I added the following code to allow the ScrollView to move and zoom the image: -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.comicImage; } This works great on the iPhone (it's a universal app) but not the iPad; I can scroll and zoom the image on the iPhone no problem, but on the iPad it's like the ScrollView isn't responding to the touches, and I can't figure out how to pass the touches on to the ScrollView. I've already deactivated the popover controller from appearing with a right swipe like this: self.splitViewController.presentsWithGesture = NO; How do I make it so the user can interact with the ScrollView in the DetailViewController?

    Read the article

  • iPhone SDK UIScrollView doesn't get touch events after moving it

    - by newbie
    Hi! I'm subclassing UIScrollView and on the start I fill this ShowsScrollView with some items. After filling it, I setup frame and contentSize to this ShowsScrollView. Everything works fine for now, i get touches events, scrolling is working.. But after rotation to landscape, I change x and y coordinates of ShowsScrollView frame, to move it from bottom to top right corner. Then I resize it (change width and height of ShowsScrollView frame) and reorder items in this scroll. At the end I setup new contentSize. Now i get touches event only on first 1/4 of scrollview, scrolling also work only on 1/4 of scrollview, but scroll all items in scrollview. After all actions I write a log: NSLog(@"ViewController: setLandscape finished: size: %f, %f content: %f,%f",scrollView.frame.size.width,scrollView.frame.size.height, scrollView.contentSize.width, scrollView.contentSize.height ); Values are correct: ViewController: setLandscape finished: size: 390.000000, 723.000000 content: 390.000000,950.000000 On rotating back to portrait, I move and resize all thing back and everything works fine.. Please help!

    Read the article

  • little more help with a CATiledLayer

    - by Brodie4598
    Okay so I am trying to adapt an online tutorial for CATiledLayer to use in my app. The example uses a PDF but I need to display a JPG. I'm getting close, but I just cant figure this out. Should I be using a UIImage or something else? #import <QuartzCore/QuartzCore.h> #import "practiceViewController.h" @implementation practiceViewController - (void)viewDidLoad { [super viewDidLoad]; NSBundle *bundle = [[NSBundle mainBundle]autorelease]; NSString *path = [bundle pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, 1600, 2400); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1024.0, 1024.0); tiledLayer.levelsOfDetail = 1000; tiledLayer.levelsOfDetailBias = 1000; tiledLayer.frame = pageRect; myContentView = [[UIView alloc] initWithFrame:pageRect]; [myContentView.layer addSublayer:tiledLayer]; CGRect viewFrame = self.view.frame; viewFrame.origin = CGPointZero; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:viewFrame]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.maximumZoomScale = 1000; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NEED HE:LP WITH THIS } @end

    Read the article

  • Scrolling with two fingers with a UIScrollView

    - by Craig
    I have an app where my main view accepts both touchesBegan and touchesMoved, and therefore takes in single finger touches, and drags. I want to implement a UIScrollView, and I have it working, but it overrides the drags, and therefore my contentView never receives them. I'd like to implement a UIScrollview, where a two finger drag indicates a scroll, and a one finger drag event gets passed to my content view, so it performs normally. Do I need create my own subclass of UIScrollView? Here's my code from my appDelegate where I implement the UIScrollView. @implementation MusicGridAppDelegate @synthesize window; @synthesize viewController; @synthesize scrollView; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch //[application setStatusBarHidden:YES animated:NO]; //[window addSubview:viewController.view]; scrollView.contentSize = CGSizeMake(720, 480); scrollView.showsHorizontalScrollIndicator = YES; scrollView.showsVerticalScrollIndicator = YES; scrollView.delegate = self; [scrollView addSubview:viewController.view]; [window makeKeyAndVisible]; } - (void)dealloc { [viewController release]; [scrollView release]; [window release]; [super dealloc]; }

    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

  • UIScrollView not showing scroll indicator

    - by George
    I have a UIScrollView which I create and size dynamically using... scrollView.contentSize = CGSizeMake(scrollView.frame.size.width , length); I then add subviews to the UIScrollView. I do have scrollView.showsVerticalScrollIndicator = YES; When scrolling the scroll indicator never appears. Even if I call [scrollView flashScrollIndicators] nothing happens. Ideas?

    Read the article

  • With and Without Dot Notation?

    - by fuzzygoat
    I am trying to write the following without using dot notation ... [scrollView setMinimumZoomScale: scrollView.bounds.size.width / image.size.width]; Is this right? [scrollView setMinimumZoomScale: [scrollView bounds].size.width / [image size].width]; cheers Gary.

    Read the article

  • Adding view to UIScrollView and toggling scrolling/interacting

    - by Peter Hajas
    Hi all! I have a UIScrollView in my project. I have a view controller I would like to add as a child of the UIScrollview. Would I just do that like this: [scrollView addSubview:theViewController.view]; or is there a better way? (theView is a view, not the TV show) Furthermore, I would like to be able to use a UIButton in scrollView's parent view controller to toggle whether or not the user is scrolling with scrollView and NOT interacting with theView or NOT scrolling with scrollview and interacting with theView. Should I just have that set the property: scrollView.userInteractionEnabled = NO; or would that disable interaction with theView because it's a child? Thanks for your help!

    Read the article

  • How to restrict bounds for Translate Animation for a view in Android?

    - by Kiran Parmar
    Hello All. Let me explain the scenario that I want to achieve:- Consider the below as the Layout I have inside a Parent_Linearlayout: [Linear Layout] (Fill_Parent, Wrap_Content) [ScrollView] Activity's setContentView is set to the Parent_Linearlayout In the application, when a condition is met, I want the Scrollview to be removed from the screen and instead put another View in its place.<br> I've been able to do this, When I remove the ScrollView, I'm applying translate Animation to it so that it seems as if the View has gone to the top, before removing it. But when the animation occurs, the ScrollView translates OVER the Linear layout present above it. How do I restrict it, so that the scrollview does not go over the linear layout, but disappears at the base of the Linearlayout. I want the linearlayout to always stay visible.. I've been trying to do this from quite some time, but I've not been able to get desired results.. Could someone kindly help me out here??

    Read the article

  • how do i scroll through 100 photos in UIScrollView in IPhone

    - by mwangima
    I'm trying to scroll through images being downloaded from a users online album (like in the facebook iphone app) since i can't load all images into memory, i'm loading 3 at a time (prev,current & next). then removing image(prev-1) & image (next +1) from the uiscroller subviews. my logic works fine in the simulator but fails in the device with this error: [CALayer retain]: message sent to deallocated instance what could be the problem below is my code sample - (void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView { pageControlIsChangingPage = NO; CGFloat pageWidth = _scrollView.frame.size.width; int page = floor((_scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; if (page1 && page<=(pageControl.numberOfPages-3)) { [self removeThisView:(page-2)]; [self removeThisView:(page+2)]; } if(page0) { NSLog(@"<< PREVIOUS"); [self showPhoto:(page-1)]; } [self showPhoto:page]; if(page<(pageControl.numberOfPages-1)) { //NSLog(@"NEXT "); [self showPhoto:page+1]; NSLog(@"FINISHED LOADING NEXT "); } } -(void) showPhoto:(NSInteger)index { CGFloat cx = scrollView.frame.size.width*index; CGFloat cy = 40; CGRect rect=CGRectMake( 0, 0,320, 480); rect.origin.x = cx; rect.origin.y = cy; AsyncImageView* asyncImage = [[AsyncImageView alloc] initWithFrame:rect]; asyncImage.tag = 999; NSURL *url = [NSURL URLWithString:[pics objectAtIndex:index]]; [asyncImage loadImageFromURL:url place:CGRectMake(150, 190, 30, 30) member:memberid isSlide:@"Yes" picId:[picsIds objectAtIndex:index]]; [scrollView addSubview:asyncImage]; [asyncImage release]; } -(void) removeThisView:(NSInteger)index { if(index<[[scrollView subviews] count] && [[scrollView subviews] objectAtIndex:index]!=nil){ if ([[[scrollView subviews] objectAtIndex:index] isKindOfClass:[AsyncImageView class]] || [[[scrollView subviews] objectAtIndex:index] isKindOfClass:[UIImageView class]]) { [[[scrollView subviews] objectAtIndex:index] removeFromSuperview]; } } } For the record it works OK in the simulator, but not the iphone device itself. any ideas will be appreciated. cheers, fred.

    Read the article

  • UIView, UIScrollView and UITextFields problem calling Method

    - by Jeff Groby
    I have a view with several embedded UITextFields, this UIView is subordinated to a UIScrollView in IB. Each text field is supposed to invoke a method called updateText defined in the viewcontroller implementation file when the user is done editing the field. For some reason, the method updateText never gets invoked. Anyone have any ideas how to go about fixing this? The method fired off just fine when the UIScrollView was not present in the project but the keyboard would cover the text fields during input, which was annoying. Now my textfields move up above the keyboard when it appears, but won't fire off the method when done editing. Here is my implementation file: #import "MileMarkerViewController.h" @implementation MileMarkerViewController @synthesize scrollView,milemarkerLogDate,milemarkerDesc,milemarkerOdobeg,milemarkerOdoend,milemarkerBusiness,milemarkerPersonal,milemarker; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Initialization code } return self; } - (BOOL) textFieldShouldReturn: (UITextField*) theTextField { return [theTextField resignFirstResponder]; } - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyboardWasShown:) name: UIKeyboardDidShowNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyboardWasHidden:) name: UIKeyboardDidHideNotification object: nil]; keyboardShown = NO; // 1 [scrollView setContentSize: CGSizeMake( 320, 480)]; // 2 } - (void)keyboardWasShown:(NSNotification*)aNotification { if (keyboardShown) return; NSDictionary* info = [aNotification userInfo]; // Get the size of the keyboard. NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey]; CGSize keyboardSize = [aValue CGRectValue].size; // Resize the scroll view (which is the root view of the window) CGRect viewFrame = [scrollView frame]; viewFrame.size.height -= keyboardSize.height; scrollView.frame = viewFrame; // Scroll the active text field into view. CGRect textFieldRect = [activeField frame]; [scrollView scrollRectToVisible:textFieldRect animated:YES]; keyboardShown = YES; } - (void)keyboardWasHidden:(NSNotification*)aNotification { NSDictionary* info = [aNotification userInfo]; // Get the size of the keyboard. NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey]; CGSize keyboardSize = [aValue CGRectValue].size; // Reset the height of the scroll view to its original value CGRect viewFrame = [scrollView frame]; viewFrame.size.height += keyboardSize.height; [scrollView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES]; scrollView.frame = viewFrame; keyboardShown = NO; } - (void)textFieldDidBeginEditing:(UITextField *)textField { activeField = textField; } - (void)textFieldDidEndEditing:(UITextField *)textField { activeField = nil; } - (IBAction)updateText:(id) sender { NSLog(@"You just entered: %@",self.milemarkerLogDate.text); self.milemarker.logdate = self.milemarkerLogDate.text; self.milemarker.desc = self.milemarkerDesc.text; self.milemarker.odobeg = self.milemarkerOdobeg.text; self.milemarker.odoend = self.milemarkerOdoend.text; self.milemarker.business = self.milemarkerBusiness.text; self.milemarker.personal = self.milemarkerPersonal.text; NSLog(@"Original textfield is set to: %@",self.milemarker.logdate); [self.milemarker updateText]; } - (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)dealloc { [super dealloc]; } @end

    Read the article

  • UIScrollView with pages enabled and device rotation/orientation changes (MADNESS)

    - by jbrennan
    I'm having a hard time getting this right. I've got a UIScrollView, with paging enabled. It is managed by a view controller (MainViewController) and each page is managed by a PageViewController, its view added as a subview of the scrollView at the proper offset. Scrolling is left-right, for standard orientation iPhone app. Works well. Basically exactly like the sample provided by Apple and also like the Weather app provided with the iPhone. However, when I try to support other orientations, things don't work very well. I've supported every orientation in both MainViewController and PageViewController with this method: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } However, when I rotate the device, my pages become quite skewed, and there are lots of drawing glitches, especially if only some of the pages have been loaded, then I rotate, then scroll more, etc... Very messy. I've told my views to support auto-resizing with theView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; But to no avail. It seems to just stretch and distort my views. In my MainViewController, I added this line in an attempt to resize all my pages' views: - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * ([self.viewControllers count]), self.scrollView.frame.size.height); for (int i = 0; i < [self.viewControllers count]; i++) { PageViewController *controller = [self.viewControllers objectAtIndex:i]; if ((NSNull *)controller == [NSNull null]) continue; NSLog(@"Changing frame: %d", i); CGRect frame = self.scrollView.frame; frame.origin.x = frame.size.width * i; frame.origin.y = 0; controller.view.frame = frame; } } But it didn't help too much (because I lazily load the views, so not all of them are necessarily loaded when this executes). Is there any way to solve this problem?

    Read the article

  • How to use drag and drop within a UIScrollView

    - by user249488
    I am trying to drag and drop UIViews within a UIScrollView. I'd like the UIScrollView to scroll if I drag a UIView so that it intersects the top or bottom of the ScrollView. If it touches the top, it should scroll up. If it touches the bottom, it should scroll down. Once the UIView is moved such that it is no longer intersecting the top or bottom, the scrolling should stop. The first approach I tried was to start an NSTimer whenever I detected that the UIView intersected with the top or bottom of the scrollview. The timer would scroll the UIScrollView bit by bit until it was invalidated. This resulted in very jerky scrolling, since there is no way to predict when the timers will fire. My current approach is to simply scroll all the way to the top or bottom of the ScrollView, like this: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:1.0]; [self.parentScrollview setContentOffset:newOffset animated:NO]; [UIView commitAnimations]; In order to stop scrolling, I try to determine the position of the touch in the touchesMoved: delegate, and use that to calculate the contentOffset to use for the scrollView. The problem is, when I try to get the location in the view via [[touches anyObject] locationInView:self], I get the final end location, rather than the current location. I'm guessing that's because the contentOffset on the scrollView is set immediately. Is there a way to get the actual location of a touch in a situation like this? Or any other way to set the contentOffset when I interrupt the scrolling animation?

    Read the article

  • Why is my addSubview: method causing a leak?

    - by Nathan
    Okay, so I have done a ton of research on this and have been pulling my hair out for days trying to figure out why the following code leaks: [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; UIImage *comicImage = [self getCachedImage:[NSString stringWithFormat:@"%@%@%@",@"http://url/",comicNumber,@".png"]]; self.imageView = [[[UIImageView alloc] initWithImage:comicImage] autorelease]; [self.scrollView addSubview:self.imageView]; self.scrollView.contentSize = self.imageView.frame.size; self.imageWidth = [NSString stringWithFormat:@"%f",imageView.frame.size.width]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; Both self.imageView and self.scrollView are @propety (nonatomic, retain) and released in my dealloc.. imageView isn't used anywhere else in the code. This code is also run in a thread off of the main thread. If I run this code on my device, it will quickly run out of memory if I continually load this view. However, I've found if I comment out the following line: [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; UIImage *comicImage = [self getCachedImage:[NSString stringWithFormat:@"%@%@%@",@"http://url/",comicNumber,@".png"]]; self.imageView = [[[UIImageView alloc] initWithImage:comicImage] autorelease]; //[self.scrollView addSubview:self.imageView]; self.scrollView.contentSize = self.imageView.frame.size; self.imageWidth = [NSString stringWithFormat:@"%f",imageView.frame.size.width]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; Memory usage becomes stable, no matter how many times I load the view. I have gone over everything I can think to see why this is leaking, but as far as I can tell I have all my releases straight. Can anyone see what I am missing?

    Read the article

  • iPhone UIScrollView / setContentOffset weirdness

    - by bibac
    Hi, I have a weird issue with setContentOffset which I don't seem to be able to solve: I'm trying to build an "endless" scroll view, so I'd like to reset the content offset at a certain position. With the code below setContentOffset will be called at x=160px. If I drag the scroll view my log looks like this: offset: 158 offset: 159 offset: 160 offset: 80 offset: 160 What happens is that my setContentOffset (to 80) is performed, when I keep on dragging UIScrollView seem to have forgotten about it and continues at 160. Even weirder: When I set animated:YES it works. Maybe a timing issue? When I call setContentOffset from within scrollViewDidScroll, scrollViewDidScroll will be called again. - (void)scrollViewDidScroll:(UIScrollView *)scrollView { NSInteger tileNo = floor(scrollView.contentOffset.x / 80); NSLog(@"offset: %f, tile: %d, lastTile: %d", scrollView.contentOffset.x, tileNo, lastTileNo); if (tileNo > lastTileNo) { [scrollView setContentOffset:CGPointMake(80, 0) animated:NO]; } lastTileNo = tileNo; } Thanks for helping me out, Stephan

    Read the article

  • Scrolling png with text & alpha on top of a static UIImageView

    - by heymon
    I have a view controller that has a view structure as follows: FilesOwner FirstResponder View ImageView (.jpg) ScrollView ImageView (.png) The text in the innermost imageview has white text and clear (alpha) all around. I want to scroll the innermost imageview, and see the background image (the .jpg) behind it. Its not working. Its acting like the scrollview background obscures the underneath .jpg. I say this because if I change the background color of the scrollview, that's what I see i.e. if I set it black, I see black behind my .png, if I set it white, I see white. If I change the alpha of the scrollview that doesn't seem to work either. The one other thing I tried was unchecking drawing: Opaque, but that doesn't get it either.

    Read the article

  • Obtaining touch location for a uiscrollview touch

    - by LOSnively
    I have a uiscrollview as an element of a uiscrollviewcontroller, along with other view objects. The image scrolls and zooms as expected, when the scrollView is the top subview. However, I also need to get the screen location of the touch, in particular when there is no scroll action. (I understand the location may change during a scroll, but that's not important.) I haven't found a way to do that. In the scrollviewcontroller implementation I have customized all of the standard methods that should do this: "touchesShouldBegin...", "touchesBegan:...", "touchesEnded:...", and so on. As far as I can tell, none of these are being called during a touch event when the scrollView is the top subview. I've tried setting the delayContentTouches property to both YES and NO, and that doesn't seem to make a difference. As an alternative, I've tried putting a UIView as the top subview and then tried passing the touches to the now underlying scrollView. In this configuration, the standard methods are called and I can get the touch location, but I haven't found a mechanism for the touches to be passed to the scrollView so scrolling occurs. Doing something like sending the touch messages to the specific scrollView, or to "super" or just sending them to nextResponder doesn't do it. It seems I can make the scroll work or find the location of the touch but not both, depending on what the "top" subview is. I suspect this is trivial, but after two weeks of struggling, it's time to eat my embarrassment for not being able to do this seemingly simplest of things. I've read all of the related questions here on stackoverflow, tried most if not all of the suggestions, and so far, nothing has worked. I've looked through the various links and references suggested by the answers, including Apple's documentation, but none have pointed out the gap in my understanding. Any ideas would be appreciated.

    Read the article

  • MIN() and MAX() in Swift and converting Int to CGFloat

    - by gotnull
    I'm getting some errors with the following methods: 1) How do I return screenHeight / cellCount as a CGFLoat for the first method? 2) How do I use the equivalent of ObjC's MIN() and MAX() in the second method? func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat { var cellCount = Int(self.tableView.numberOfRowsInSection(indexPath.section)) return screenHeight / cellCount as CGFloat } // #pragma mark - UIScrollViewDelegate func scrollViewDidScroll(scrollView: UIScrollView) { let height = CGFloat(scrollView.bounds.size.height) let position = CGFloat(MAX(scrollView.contentOffset.y, 0.0)) let percent = CGFloat(MIN(position / height, 1.0)) blurredImageView.alpha = percent }

    Read the article

  • Connect two UIScrollView's together

    - by johnw188
    Here's a tricky iPhone problem I've been working on. I have three UIScrollViews on a page, one that only scrolls horizontally, one that only scrolls vertically, and one that scrolls both horizontally and vertically. I want to lock the views together, so that the horizontal location of the horizontal only scrollview matches the horizontal location of the main scrollview, and the vertical scrollview likewise, so that dragging the main scrollview around controls the horizontal and vertical scrollviews. Problem is, I'm completely stumped. I've looked around inside the apple documentation, but there doesn't seem to be any way to do this officially. One thought that I had was to somehow "clone" any touch on any of the scrollviews to a point on the other two, but I have no idea how to do this. If anyone has any thoughts on this, I'd very much appreciate it.

    Read the article

  • Casting to specify unknown object type?

    - by fuzzygoat
    In the following code I have a view object that is an instance of UIScrollView, if I run the code below I get warnings saying that "UIView might not respond to -setContentSize etc." UIImage *image = [UIImage imageNamed:@"Snowy_UK.jpg"]; imageView = [[UIImageView alloc] initWithImage:image]; [[self view] addSubview:imageView]; [[self view] setContentSize:[image size]]; [[self view] setMaximumZoomScale:2.0]; [[self view] setMinimumZoomScale: [[self view] bounds].size.width / [image size].width]; I have checked the type of the object and [self view] is indeed a UIScrollView. I am guessing that this is just the compiler making a bad guess as to the type and the solution is simply to cast the object to the correct type manually, am I getting this right? UIScrollView *scrollView = (UIScrollView *)[self view]; UIImage *image = [UIImage imageNamed:@"Snowy_UK.jpg"]; imageView = [[UIImageView alloc] initWithImage:image]; [[self view] addSubview:imageView]; [scrollView setContentSize:[image size]]; [scrollView setMaximumZoomScale:2.0]; [scrollView setMinimumZoomScale: [scrollView bounds].size.width / [image size].width]; cheers Gary.

    Read the article

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