Search Results

Search found 1125 results on 45 pages for 'uiview'.

Page 10/45 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • UIButton performance in UITableViewCell vs UIView

    - by marcel salathe
    I'd like to add a UIButton to a custom UITableViewCell (programmatically). This is easy to do, but I'm finding that the "performance" of the button in the cell is slow - that is, when I touch the button, there is quite a bit of delay until the button visually goes into the highlighted state. The same type of button on a regular UIView is very responsive in comparison. In order to isolate the problem, I've created two views - one is a simple UIView, the other is a UITableView with only one UITableViewCell. I've added buttons to both views (the UIView and the UITableViewCell), and the performance difference is quite striking. I've searched the web and read the Apple docs but haven't really found the cause of the problem. My guess is that it somehow has to do with the responder chain, but I can't quite put my finger on it. I must be doing something wrong, and I'd appreciate any help. Thanks. Demo code: ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> @property UITableView* myTableView; @property UIView* myView; ViewController.m #import "ViewController.h" #import "CustomCell.h" @implementation ViewController @synthesize myTableView, myView; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { [self initMyView]; [self initMyTableView]; } return self; } - (void) initMyView { UIView* newView = [[UIView alloc] initWithFrame:CGRectMake(0,0,[[UIScreen mainScreen] bounds].size.width,100)]; self.myView = newView; // button on regularView UIButton* myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [myButton addTarget:self action:@selector(pressedMyButton) forControlEvents:UIControlEventTouchUpInside]; [myButton setTitle:@"I'm fast" forState:UIControlStateNormal]; [myButton setFrame:CGRectMake(20.0, 10.0, 160.0, 30.0)]; [[self myView] addSubview:myButton]; } - (void) initMyTableView { UITableView *newTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,100,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height-100) style:UITableViewStyleGrouped]; self.myTableView = newTableView; self.myTableView.delegate = self; self.myTableView.dataSource = self; } -(void) pressedMyButton { NSLog(@"pressedMyButton"); } - (void)viewDidLoad { [super viewDidLoad]; [[self view] addSubview:self.myView]; [[self view] addSubview:self.myTableView]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomCell *customCell = [tableView dequeueReusableCellWithIdentifier:@"CustomCell"]; if (customCell == nil) { customCell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"CustomCell"]; } return customCell; } @end CustomCell.h #import <UIKit/UIKit.h> @interface CustomCell : UITableViewCell @property (retain, nonatomic) UIButton* cellButton; @end CustomCell.m #import "CustomCell.h" @implementation CustomCell @synthesize cellButton; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // button within cell cellButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [cellButton addTarget:self action:@selector(pressedCellButton) forControlEvents:UIControlEventTouchUpInside]; [cellButton setTitle:@"I'm sluggish" forState:UIControlStateNormal]; [cellButton setFrame:CGRectMake(20.0, 10.0, 160.0, 30.0)]; [self addSubview:cellButton]; } return self; } - (void) pressedCellButton { NSLog(@"pressedCellButton"); } @end

    Read the article

  • iPhone: how do i redraw subviews while pinch zooming a uiscrollview

    - by Mike
    I am developing an iPhone app that places multiple custom UIViews as subviews in a UIScrollView. The subviews are placed on top of each other as transparent views as each view has its own drawing routines that traces parts of the base view. The base view is a UIImageView that is typically a large image that I want the user to be able to pan and zoom in and out of. The problem I am having is that when I zoom in and out of my UIScrollView, the subviews do not redraw themselves while the user is zooming. I can reposition and scale the subviews properly once the zoom is completed, but the user experience is less than desirable. I have not been able to find a way to either hide or redraw the subviews as the zoom is taking place to scale the subviews along with the ImageView. Any ideas? thanks! Here is the code that I have implemented: - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { for (UIView *view in subViews) { [view updateView:scale]; } } - (UIView *)viewForZoomingInScrollView:(UIScrollView *) scrollView { return imageView; }

    Read the article

  • UIKeyBoard resize on orientation change to landscape

    - by Dave
    This is very rookie question. I have a UIToolBar at the bottom which is supposed to animatedly move up and down with key board when the UIKeyBoard is displayed. I got that working with the help of UIKeyBoard Notifications. The view we are talking about has split view enabled. When device orientation is landscape, both the views as columns are shown [hope that makes sense]. When key board is shown, i do this CGSize keyBoardSize = [[notificationInfo objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size; CGRect toolbarFrame= [BottomToolBar frame]; toolbarFrame.origin.y -= keyBoardSize.height; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3]; BottomToolBar .frame = viewFrame; [UIView commitAnimations]; when key board is hiiden i do this toolbarFrame.origin.y += keyBoardSize.height; My Problem is when device orientation changes to landscape, when the key board is visible the bottom tool bar is gone. I see it move up quickly. I am not sure how to fix this. Can anyone help please? Also, is there a way to NOT make the key board span across both the views in the split view?

    Read the article

  • How do you update a secondary view?

    - by Troy Sartain
    Perhaps there's a better way to set this up so I'm open to suggestions. But here's what I'm doing. I have a main UIView. On top of that I have a UIImageView and another UIView. When the UIImageView changes, I want to change the second UIView. So I have a class for it and the IB object's type is set to the class. In the .m of that class is a drawRect method that draws some rectangles. Also in the .m is a NSMutableArray property that is synthesized. I created an instance of that class in the controller of the main view. The problem: despite the fact that the drawRect works fine when the app starts (as traced in the debugger,) when the UIImageView changes I call a "setNeedsDisplay" on the instance variable of the second view after updating the @synthesize'd array but the drawRect does not get called. I think it has to do with instances. I wouldn't think threading would be an issue here. I just want to draw in a separate area of the screen based on an image also displayed.

    Read the article

  • UITapGestureRecognizer recognizing tap after scaling UIView

    - by Bikash Mishra
    I have a UIView which I scale to 4x after tapping on it. It works fine. On the next tap I want to restore it back to original size. The problem is that it recognizes the tap only in the smaller rectangle the UIView had before scaling. I would like to recognize the tap anywhere in the scaled UIView. How can I achieve it? //Tapping code titleCard = [[UIView alloc] initWithFrame: myrect]; [self addSubview:titleCard]; [titleCard release]; UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeSize:)]; [tapRecognizer setNumberOfTouchesRequired:1]; [tapRecognizer setNumberOfTapsRequired:1]; [titleCard addGestureRecognizer:tapRecognizer]; [tapRecognizer release]; //Scaling code CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; [scale setBeginTime:CACurrentMediaTime()+0.75]; [scale setDuration:0.5]; [scale setToValue: [NSNumber numberWithFloat:4.0f]]; [scale setRemovedOnCompletion:NO]; [scale setFillMode:kCAFillModeForwards]; Thanks.

    Read the article

  • Scaling MKMapView Annotations relative to the zoom level

    - by Jonathan
    The Problem I'm trying to create a visual radius circle around a annonation, that remains at a fixed size in real terms. Eg. So If i set the radius to 100m, as you zoom out of the Map view the radius circle gets progressively smaller. I've been able to achieve the scaling, however the radius rect/circle seems to "Jitter" away from the Pin Placemark as the user manipulates the view. The Manifestation Here is a video of the behaviour. The Implementation The annotations are added to the Mapview in the usual fashion, and i've used the delegate method on my UIViewController Subclass (MapViewController) to see when the region changes. -(void)mapView:(MKMapView *)pMapView regionDidChangeAnimated:(BOOL)animated{ //Get the map view MKCoordinateRegion region; CGRect rect; //Scale the annotations for( id<MKAnnotation> annotation in [[self mapView] annotations] ){ if( [annotation isKindOfClass: [Location class]] && [annotation conformsToProtocol:@protocol(MKAnnotation)] ){ //Approximately 200 m radius region.span.latitudeDelta = 0.002f; region.span.longitudeDelta = 0.002f; region.center = [annotation coordinate]; rect = [[self mapView] convertRegion:foo toRectToView: self.mapView]; if( [[[self mapView] viewForAnnotation: annotation] respondsToSelector:@selector(setRadiusFrame:)] ){ [[[self mapView] viewForAnnotation: annotation] setRadiusFrame:rect]; } } } The Annotation object (LocationAnnotationView)is a subclass of the MKAnnotationView and it's setRadiusFrame looks like this -(void) setRadiusFrame:(CGRect) rect{ CGPoint centerPoint; //Invert centerPoint.x = (rect.size.width/2) * -1; centerPoint.y = 0 + 55 + ((rect.size.height/2) * -1); rect.origin = centerPoint; [self.radiusView setFrame:rect]; } And finally the radiusView object is a subclass of a UIView, that overrides the drawRect method to draw the translucent circles. setFrame is also over ridden in this UIView subclass, but it only serves to call [UIView setNeedsDisplay] in addition to [UIView setFrame:] to ensure that the view is redrawn after the frame has been updated. The radiusView object's (CircleView) drawRect method looks like this -(void) drawRect:(CGRect)rect{ //NSLog(@"[CircleView drawRect]"); [self setBackgroundColor:[UIColor clearColor]]; //Declarations CGContextRef context; CGMutablePathRef path; //Assignments context = UIGraphicsGetCurrentContext(); path = CGPathCreateMutable(); //Alter the rect so the circle isn't cliped //Calculate the biggest size circle if( rect.size.height > rect.size.width ){ rect.size.height = rect.size.width; } else if( rect.size.height < rect.size.width ){ rect.size.width = rect.size.height; } rect.size.height -= 4; rect.size.width -= 4; rect.origin.x += 2; rect.origin.y += 2; //Create paths CGPathAddEllipseInRect(path, NULL, rect ); //Create colors [[self areaColor] setFill]; CGContextAddPath( context, path); CGContextFillPath( context ); [[self borderColor] setStroke]; CGContextSetLineWidth( context, 2.0f ); CGContextSetLineCap(context, kCGLineCapSquare); CGContextAddPath(context, path ); CGContextStrokePath( context ); CGPathRelease( path ); //CGContextRestoreGState( context ); } Thanks for bearing with me, any help is appreciated. Jonathan

    Read the article

  • Infinite loop when adding CATiledLayer to UIView

    - by Jean
    I have a UIView in which I add a CATiledLayer and implement 'drawLayer'. If I use a UIViewController and add the layer to a new subview of the controller, then everything is ok. If I however try to use a UIView to and do all the craetion and drawing within this, then I get a infinite loop at the point shown below when I add this view to a superview. 0x002cfafb <+0425> ja 0x2cfa23 <-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]+209> What am I missing?

    Read the article

  • Memory over-release problem when I am animating UIView

    - by Sheehan Alam
    I have enabled NSZombie's and I am getting the following message in my console when I am running my application: *** -[UIViewAnimationState release]: message sent to deallocated instance 0xf96d7e0 Here is the method that is performing the animation -(void)loadAvatar:(STObject*)st { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; avatar.alpha = 0; avatar.frame = avatarRectSmall; avatar.image = [ImageCache getMemoryCachedImageAtUrl:st.avatar_url]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.50]; avatar.frame = avatarRectNormal; [avatar setAlpha:1]; [UIView commitAnimations]; [pool release]; pool = nil; } I don't always get a crash, only sometimes. I'm wondering what is getting released?

    Read the article

  • Are UIView's in TableViewCells cause for performance problems?

    - by iFloh
    Hi, I have a UITableView of UITableViewCells that so far performed well. I now aded a simple UIView to my UITableViewCell as a color indicator (backgroundColor only, no other content or attributes). Running the tableview again I realise scrolling is not as smooth as it used to be. The tableView suddenly also takes long time (~1+ secs) to come back again when returning from a subview (e.g. return from the view that gets pushed upon selection of a cell). Any ideas why the added UIView would be problematic? Why are the labels (being a subclass of UIView) not cause for similar issues?

    Read the article

  • How to make the subview in a UIScrollView to refresh when we zoom it?

    - by wolverine
    I have subclassed UIView object inside a uiscrollview which displays a pdf page. I can zoom that page. But when I do so, the inside view is zoomed and is getting blurred. I understood that the inner view shud be refreshed and i called setNeedsDisplay. But no change have happened and its the same even now. Below is the code for drawRect for the subclassed uiview. - (void)drawRect:(CGRect)rect { if(document)//the pdf document object { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); CGContextTranslateCTM(ctx, 0.00, [self bounds].size.height); NSLog(@"%f",[self bounds].size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, [self bounds], 0, true)); CGContextDrawPDFPage(ctx, page); CGContextRestoreGState(ctx); } }

    Read the article

  • How to transform (rotate) a already exist CALayer/animation?

    - by Flocked
    Hello, I have added a CALayer to the UIView of my app: CATransition *animation = [CATransition animation]; [animation setDelegate:self]; [animation setDuration:0.35]; [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; animation.type = @"pageCurl"; animation.fillMode = kCAFillModeForwards; animation.endProgress = 0.58; [animation setRemovedOnCompletion:NO]; [[self.view layer] addAnimation:animation forKey:@"pageCurlAnimation"]; Now when the user rotates the device, the layer always stays in the same position on the screen (in line to the homescreen button). Is it possible to rotate the animation/layer? I tried self.view.layer.transform = CGAffineTransformMakeRotation (angle); but this code just rotates the UIView and not the animation/layer I set.

    Read the article

  • iphone screen - type of view to use

    - by Fiona
    Hi There everyone... looking for some advice on what type of view can be used to build a screen with the following elements: 2 labels followed by 2 buttons. Then a small table view with 3 rows. Should a UIView be used or a UITableView? I've attempted using a UITableView - however I couldn't add the labels or buttons. So I've now built the view using a UIView. I added the labels and buttons and then a UITableView from the library. However I have no idea how to populate the rows in the table? Any ideas? Regards, Fiona

    Read the article

  • How does one access subviews and handle groups of them?

    - by david
    If I want to manipulate a view I get it with [self viewWithTag:5];. Is there a better way to do this? Sometimes I need to manipulate a bunch of view (e.g. move them all out of the way. I do this by adding a UIView (e.g. UIView iHoldViews) and then adding the views, buttons, etc to this view. Then I can move the iHoldViews view and all its subviews move with it. Is there a better way to do this? (I have a feeling there is :) Maybe storing them in a NSArray or NSMutableDictionary ?

    Read the article

  • UIWebView or Custom UIView

    - by dinoc
    I have a dilemma and was wondering if anyone else had this issue. I have a Navigation based app that when you drill down to the last level, that last view has lots and lots of information and details. I am wondering if I should just use a UIWebView to display the details of information or if I should create a custom UIView with all the labels and outlets set in that UIView. Which way is recommended or the preferred way of doing something like this?

    Read the article

  • uiview rotation reset size problem

    - by user564968
    i have uiview i have rotate view left and right side ...i m transform view ...but problem is view fream is not changing... my code is like this ... CGAffineTransform tRotate45 = CGAffineTransformMakeRotation(-1.57); self.view.transform = tRotate45; imageScrollView.contentSize = CGSizeMake(480, 320); self.view.frame =[[UIView alloc] ] CGRectMake(0, 0, 480, 320); view is showing proper how can i adjust this ...

    Read the article

  • pulling an UIImage from a UITextView or UILabel gives white image

    - by user293139
    Hello all, I need to grab an UIImage from a UITextView or UILabel. I've got a method that will pull an image successfully from other types of views ( [UIViewController view], MKMapView, UIButtons) but I am just getting a white rect for my UITextView. I've been banging my head against the wall for a while and suspect something really, really basic. many thanks! @interface TaskAccomplishmentViewController : UIViewController { MKMapView *mapView; UILabel *timeLeftText; UITextView *challengeText; UIButton *successButton; -(void) setChallangeImageToImageFromChallenge { // works // [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:mapView]]; // [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:[self view]]]; // [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:successButton]]; //doesn't work // [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:timeLeftText]]; [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:challengeText]]; } and the grabImage from a UIView code +(UIImage *)grabImageFromView: (UIView *) viewToGrab { UIGraphicsBeginImageContext(viewToGrab.bounds.size); [[viewToGrab layer] renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return viewImage; }

    Read the article

  • UITableView Section Headers Drawing Above Front Subview

    - by hadronzoo
    I have a UITableView whose data have sections. I display an overlay view on top of tableView that dims it when searching: - (UIView *)blackOverlay { if (!blackOverlay) { blackOverlay = [[UIView alloc] initWithFrame:[self overlayFrame]]; blackOverlay.alpha = 0.75; blackOverlay.backgroundColor = UIColor.blackColor; [tableView insertSubview:blackOverlay aboveSubview:self.parentViewController.view]; } return blackOverlay; } This works perfectly as long as tableView does not contain sections. When tableView does contain sections and the tableView updates (such as when the view reappears after popping a view off of the navigation controller stack), the section headers are rendered above blackOverlay. This leaves tableView dimmed except for the section headers. I've tried calling [tableView bringSubviewToFront:self.blackOverlay] from within viewWillAppear:, but I get the same behavior. My current work-around is returning nil for tableView section headers while the overlay is present, but this leaves whitespace gaps in the overlaid tableView where the section headers were previously. How can I insure that tableView section headers are never drawn above blackOverlay? Or, is it possible to create a view in front of tableView from within a UITableViewController subclass that is not a subview of tableView?

    Read the article

  • How can I create "glass" effect on my own UIViews?

    - by lindes
    Hi there, I'm working on an iPhone app that has some non-rectangular UI elements. Currently, I'm subclassing UIView, and in drawRect I'm using a CGPathRef to draw black border and a color-filled interior. I'd like to make these items look more like "buttons", though, so I'd like to have some of the same sort of "glass effects" that are used on e.g. the icons for an iPhone app (when you don't set UIPrerenderedIcon to true), or in other buttons. I hunted around, and found this, which seems to be close to what I need: http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone But I'm having difficulty figuring out how to clip the gradient to my shape. It seems like the mask property on the view would be the right place to go, which seems like it would call for me to create a new CALayer object, with the clipping somehow applied to it. I'm hoping there's some nice convenience function for doing this, though if I need to write something more complicated, that's OK, too. I'm just having difficulty figuring out how to apply the path as a mask. I'm unsure if I need to create a new drawing context and draw the path into it? And then use CGContextClip? I think I've got a lot of the right pieces figured out, I'm just having difficulty understanding how to assemble them. Could someone please point me in the right direction? (I'm happy to read more in the docs, just point me in the right direction, please.)

    Read the article

  • UIActivityIndicatorView in a class without a view

    - by Structurer
    Hi I have defined a class that does a lengthy task and I call it from several other classes. Now I want to show an Activity Indicator while this task is doing it's thing, and then remove it once it's done. Since this is just a boring background task, this class doesn't have a view, and I guess that is where I run into my problem. I can't get this thing to show. This is what I have done in my class: UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)]; [activityIndicator setCenter:CGPointMake(160.0f, 208.0f)]; activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite; UIView *contentView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]]; [contentView addSubview:activityIndicator]; [activityIndicator startAnimating]; // Do the class lengthy task that takes several seconds..... [contentView release]; [activityIndicator release]; I guess I do something wrong when I get the contentView, but how should I get it properly? Thanks for any advices...

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >