Search Results

Search found 2691 results on 108 pages for 'ios 4'.

Page 55/108 | < Previous Page | 51 52 53 54 55 56 57 58 59 60 61 62  | Next Page >

  • How Do I Bind a UIButton Property to Another Property?

    - by cygnl7
    UIButton eventually inherits from NSObject, and NSObject implements NSKeyValueBindingCreation Protocol. So why can't I bind a UIButton's property to another class' property? [myUIButton bind:@"enabled" toObject:myOtherObject withKeyPath:@"otherObjectBOOLProperty" options:nil]; This results in the warning 'UIButton' may not respond to '-bind:toObject:withKeyPath:options:' What I'm trying to do is bind the enabled state of my UIButton to myOtherObject.otherObjectBOOLProperty.

    Read the article

  • Rendering a CGPDFPage into a UIImage

    - by James Antrobus
    I'm trying to render a CGPDFPage (selected from a CGPDFDocument) into a UIImage to display on a view. I have the following code in MonoTouch which gets me part way there. RectangleF PDFRectangle = new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); public override void ViewDidLoad () { UIGraphics.BeginImageContext(new SizeF(PDFRectangle.Width, PDFRectangle.Height)); CGContext context = UIGraphics.GetCurrentContext(); context.SaveState(); CGPDFDocument pdfDoc = CGPDFDocument.FromFile("test.pdf"); CGPDFPage pdfPage = pdfDoc.GetPage(1); context.DrawPDFPage(pdfPage); UIImage testImage = UIGraphics.GetImageFromCurrentImageContext(); pdfDoc.Dispose(); context.RestoreState(); UIImageView imageView = new UIImageView(testImage); UIGraphics.EndImageContext(); View.AddSubview(imageView); } A section of the CGPDFPage is displayed but rotated back-to-front and upside down. My question is, how do I select the full pdf page and flip it round to display correctly. I have seen a few examples using ScaleCTM and TranslateCTM but couldn't seem to get them working. Any examples in ObjectiveC are fine, I'll take all the help I can get :) Thanks

    Read the article

  • Passing UITableView's with parsing XML

    - by Luai Kalkatawi
    I am parsing XML and I select from the UITablevView but I have an issue that how I am going to change the link on each selection? For example; www.example.com/test12.php?d=0 www.example.com/test12.php?d=1&il=istanbul www.example.com/test12.php?d=2&il=istanbul&ilce=kadikoy How can I change the d= and il= and ilce= value on each select on the UITableView? I have write this but couldn't go further. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; NSString *cellText = selectedCell.textLabel.text; NSString *linkID = @"http://example/test12.php?d=@%&il=@%"; NSLog(@"%@ Selected", cellText); } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; containerObject = [objectCollection objectAtIndex:indexPath.row]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } // Set up the cell... cell.textLabel.text = containerObject.city; return cell; } Thanks from now.

    Read the article

  • autorelease object not confirming protocol does not give any warning

    - by Sahil Wasan
    I have a class "ABC" and its method which returns non autoreleases object of that class. @interface ABC:NSObject +(ABC *)aClassMethodReturnsObjectWhichNotAutoreleased; @end @implementation ABC +(ABC *)aClassMethodReturnsObjectWhichNotAutoreleased{ ABC *a = [[ABC alloc]init]; return a; } @end If I have a protocol Foo. @Protocol Foo @required -(void)abc; @end My ABC class is "not" confirming Foo protocols. 1st call id<Foo> obj = [ABC aClassMethodReturnsObjectWhichNotAutoreleased]; //show warning It shows warning "Non Compatible pointers.." thats good.Abc did not confirm protocol Foo BUT 2nd call id<Foo> obj = [NSArray arrayWithObjects:@"abc",@"def",nil]; // It will "not" show warning as it will return autorelease object.NSArray don't confirm protocol Foo In first call compiler gives warning and in second call compiler is not giving any warning.I think that is because i am not returning autorelease object. Why is compiler not giving warning in 2nd call as NSArray is also not confirming FOO Thanks in advance

    Read the article

  • Strange behavior: save video recorded within app?

    - by Josue Espinosa
    I allow the user to record a video within my app, then later play it again. When a user records a video, I save the URL of the video, then play the video later from the saved URL. I save the video both in the Photos app and in my app. If I delete the video within the photos app, it still plays. After about 7 days, the video gets deleted. I think I am saving in my tmp directory, but i'm not sure. Here is what I am doing: -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; [self dismissViewControllerAnimated:YES completion:nil]; // Handle a movie capture if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) { NSString *moviePath = [NSString stringWithFormat:@"%@",[[info objectForKey:UIImagePickerControllerMediaURL] path]]; NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; NSData *videoData = [NSData dataWithContentsOfURL:videoURL]; _justRecordedVideoURL = [NSString stringWithFormat:@"%@",videoURL]; AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; _managedObjectContext = [appDelegate managedObjectContext]; Video *video = [NSEntityDescription insertNewObjectForEntityForName:@"Video" inManagedObjectContext:_managedObjectContext]; [video setVideoData:videoData]; [video setVideoURL:[NSString stringWithFormat:@"%@",videoURL]]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateStyle = NSDateFormatterLongStyle; [dateFormatter setDateStyle:NSDateFormatterLongStyle]; NSDate *date = [dateFormatter dateFromString:[dateFormatter stringFromDate:[NSDate date]]]; NSString *dateAdded = [dateFormatter stringFromDate:date]; [video setDate_recorded:dateAdded]; if(_currentAthlete != nil){ [video setWhosVideo:_currentAthlete]; } NSError *error = nil; if(![_managedObjectContext save:&error]){ //handle dat error } NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"]; BOOL success = [videoData writeToFile:tempPath atomically:NO]; if(success == FALSE){ NSLog(@"Video was not successfully saved."); } if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)) { UISaveVideoAtPathToSavedPhotosAlbum(moviePath, self, @selector(video:didFinishSavingWithError:contextInfo:), nil); } } } Am I saving it incorrectly? When I go to play the video, it works fine, after a couple days the video will play without audio, then eventually it will be gone. Any ideas why?

    Read the article

  • Core Plot: x-axis labels not plotted when using scaleToFitPlots

    - by AlexR
    Problem: I can't get Core Plot (1.1) to plot automatic labels for my x-axis when using autoscaling ([plotSpace scaleToFitPlots:[graph allPlots]). What I have tried: I changed the values for the offsets and paddings, but this did not change the result. However, when turning autoscale off (not using [plotSpace scaleToFitPlots:[graph allPlots]]and setting the y scale automatically, the automatic labeling of the x-axis works. Question: Is there a bug in Core Plot or what did I do wrong? I would appreciate any help! Thank you! This is how I have set up my chart: CPTBarPlot *barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO]; barPlot.baseValue = CPTDecimalFromInt(0); barPlot.barOffset = CPTDecimalFromFloat(0.0f); // CPTDecimalFromFloat(0.5f); barPlot.barWidth = CPTDecimalFromFloat(0.4f); barPlot.barCornerRadius = 4; barPlot.labelOffset = 5; barPlot.dataSource = self; barPlot.delegate = self; graph = [[CPTXYGraph alloc]initWithFrame:self.view.bounds]; self.hostView.hostedGraph = graph; graph.paddingLeft = 40.0f; graph.paddingTop = 30.0f; graph.paddingRight = 30.0f; graph.paddingBottom = 50.0f; [graph addPlot:barPlot]; graph.plotAreaFrame.masksToBorder = NO; graph.plotAreaFrame.cornerRadius = 0.0f; graph.plotAreaFrame.borderLineStyle = borderLineStyle; double xAxisStart = 0; CPTXYAxisSet *xyAxisSet = (CPTXYAxisSet *)graph.axisSet; CPTXYAxis *xAxis = xyAxisSet.xAxis; CPTMutableLineStyle *lineStyle = [xAxis.axisLineStyle mutableCopy]; lineStyle.lineCap = kCGLineCapButt; xAxis.axisLineStyle = lineStyle; xAxis.majorTickLength = 10; xAxis.orthogonalCoordinateDecimal = CPTDecimalFromDouble(yAxisStart); xAxis.paddingBottom = 5; xyAxisSet.delegate = self; xAxis.delegate = self; xAxis.labelOffset = 0; xAxis.labelingPolicy = CPTAxisLabelingPolicyAutomatic; [plotSpace scaleToFitPlots:[graph allPlots]]; CPTMutablePlotRange *yRange = plotSpace.yRange.mutableCopy; [yRange expandRangeByFactor:CPTDecimalFromDouble(1.3)]; plotSpace.yRange = yRange; NSInteger xLength = CPTDecimalIntegerValue(plotSpace.xRange.length) + 1; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(xAxisStart) length:CPTDecimalFromDouble(xLength)] ;

    Read the article

  • How to call a method from another class that's been instantiated within the current class

    - by Pavan
    my screen has a few views like such __________________ | _____ | | | | | //viewX is a video screen | | | | | viewX | vY | | //viewY is a custom uiview i created. | |____| | //it contains a method which i would like to call that toggles |_________________| //the hidden property of this view. and when it hides, a little | | //button is replaced no the top right corner on top of viewX | viewZ | //the video layer | | |_________________| //viewZ is a view containing many square views - thumbnails. my question is, i dont know how to register for touch events so that it recognises any touch event on no matter which view the user touches the screen.. atm im handling the touch events for each view inside it. so all works well... however what im trying to do is that when the user taps anywhere else on the screen but on viewY, viewY should dissapear by calling that method in the viewY class. this viewY class is instantiated and has no xib file attached to it. the uiview is created progammatically in the viewY class. this whole class for viewY behviour is instantiated in viewX - the video view. my boss says add delegates.. although i have now clue how to do that... any help? is there anyway i can just make it really simple and be able to say REMOVE VIEW no matter which class im calling from? Also ive seen other people achieve this by using these funky arrows - ... <- etc.. although im not sure if thats what i need or how to implement such a thing. ah i think ive made my question quite complicated but i really mean it to be a simple one, and know it can be done in an easy way!

    Read the article

  • Vertically align UILabel

    - by Ashish Agarwal
    I am trying to vertically align the text in the UILabel view of my app. The problem is that I want the text to be vertically aligned to the top and the size of the label to be 280 x 150. I am only able to achieve one of these 2 things. If I remove the line [myLabel sizeToFit]; then the alignment of the text is alright but the size is messed up. But if I add the above line, then the alignment is messed up but the size is alright. How do I fix this problem. I've added the code below - CGRect labelFrame = CGRectMake(22, 50, 280, 150); UILabel *myLabel = [[UILabel alloc] initWithFrame:labelFrame]; [myLabel setText:finalRecipe]; [myLabel setBackgroundColor: [UIColor lightGrayColor]]; [myLabel setNumberOfLines:0]; [myLabel sizeToFit]; [self.view addSubview:myLabel];

    Read the article

  • UITableViewRowAnimationBottom doesn't work for last row

    - by GendoIkari
    I've come across a very similar question here: Inserting row to end of table with UITableViewRowAnimationBottom doesn't animate., though no answers have been given. His code was also a little different than mine. I have an extremely simple example, built from the Navigation application template. NSMutableArray *items; - (void)viewDidLoad { [super viewDidLoad]; items = [[NSMutableArray array] retain]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addItem)] autorelease]; } - (void)addItem{ [items insertObject:@"new" atIndex:0]; [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationBottom]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return items.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [items objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [items removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom]; } } The problem is, when I either insert or delete the very last row in the table, the animation doesn't work at all; the row just appears or disappears instantly. This only happens with UITableViewRowAnimationBottom, but that's the animation that makes the most sense for creating or deleting table cells in this way. Is this a bug in Apple's framework? Or does it do this on purpose? Would it make sense to add an extra cell to the count, and then setup this cell so that it looks like it's not there at all, just to get around this behavior?

    Read the article

  • Releasing an NSTimer iPhone?

    - by Conor Taylor
    I have an NSTimer declared in my .h and in the viewDidLoad of the /m I have the code: timer = [NSTimer scheduledTimerWithTimeInterval:kComplexTimer target:self selector:@selector (main) userInfo:nil repeats:YES]; I also have [timer release]; in my dealloc. However when I exit the view and return to it, the timer has not in fact released, it has doubles in speed! How do I solve this & what am I doing wrong??? Thanks

    Read the article

  • Iphone remove sub view

    - by Sharanya
    I have a UINavigationController. On the right top i have a button on click of which i have to get a drop down table view. I created another UIViewController Class, with xib and added it as a subView to the current view. It should appear on 1st click and disappear on the 2nd click. This should happen for all click(open view and close view). I wrote this code but dont know where i'm going wrong. someone please help -(void)modalTableView { tableView1 = [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:nil]; for (UIView *subView in self.view.subviews) { if ([subView isKindOfClass:[TableViewController class]]) { [subView removeFromSuperview]; } else { [self.view addSubview:tableView1.view]; } } } What am i missing here? EDIT : TableViewController is the name of my UIViewController Class

    Read the article

  • Determining where in the code an error came from - iPhone

    - by Robert Eisinger
    I'm used to Java programming where an error is thrown and it tells you at what line the error was thrown from which file. But with Objective-C in XCode, I can't ever tell where the error comes from. How can I figure out where the error came from? Here is an example of a crash error: 2011-01-04 10:36:31.645 TestGA[69958:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array' *** Call stack at first throw: ( 0 CoreFoundation 0x01121be9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x012765c2 objc_exception_throw + 47 2 CoreFoundation 0x011176e5 -[__NSArrayM objectAtIndex:] + 261 3 TestGA 0x000548d8 -[S7GraphView drawRect:] + 5763 4 UIKit 0x003e16eb -[UIView(CALayerDelegate) drawLayer:inContext:] + 426 5 QuartzCore 0x00ec89e9 -[CALayer drawInContext:] + 143 6 QuartzCore 0x00ec85ef _ZL16backing_callbackP9CGContextPv + 85 7 QuartzCore 0x00ec7dea CABackingStoreUpdate + 2246 8 QuartzCore 0x00ec7134 -[CALayer _display] + 1085 9 QuartzCore 0x00ec6be4 CALayerDisplayIfNeeded + 231 10 QuartzCore 0x00eb938b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 325 11 QuartzCore 0x00eb90d0 _ZN2CA11Transaction6commitEv + 292 12 QuartzCore 0x00ee97d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 13 CoreFoundation 0x01102fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27 14 CoreFoundation 0x010980e7 __CFRunLoopDoObservers + 295 15 CoreFoundation 0x01060bd7 __CFRunLoopRun + 1575 16 CoreFoundation 0x01060240 CFRunLoopRunSpecific + 208 17 CoreFoundation 0x01060161 CFRunLoopRunInMode + 97 18 GraphicsServices 0x01932268 GSEventRunModal + 217 19 GraphicsServices 0x0193232d GSEventRun + 115 20 UIKit 0x003b842e UIApplicationMain + 1160 21 TestGA 0x00001cd8 main + 102 22 TestGA 0x00001c69 start + 53 23 ??? 0x00000001 0x0 + 1 So from looking at this, where is the error coming from and from which class is it coming from?

    Read the article

  • How to pass a touch event to other views?

    - by Eugene
    +-----------------------+ +--------------------+ | A | | A | | +-------------------+ | | +----------------+ | | |B | | | | C | | | | | | | | | | | +-------------------+ | | +----------------+ | +-----------------------+ +--------------------+ I have a view hierarchy as above. (Each of B and C takes up whole space of A, Each of them are screen size. B is added first and C is added next) For a reason, C is getting a touch event for scroll effect (B is cocos2d-x layer and C(scroll view) sets the B's position when scrollViewDidScroll http://getsetgames.com/2009/08/21/cocos2d-and-uiscrollview/ ) And I want to pass touch event to B or it's subviews when it's not scrolling. How can I pass the touch event to B here?

    Read the article

  • Adding an Image to the calendar View in Iphone

    - by sadumerry
    I need to add an image at the top of the default calendar view of the iPhone. If any body knows how to implement this please respond.I am using the Tapku library inorder to show the calendar. Kal library also can be used if this can implement there. Below attached the calendar view and i need to put an image at the top of this calendar just below the title bar.The calendar need to see just below the image.

    Read the article

  • Looping through NSArray while subtracting values from each object? [on hold]

    - by Julian
    I have NSNumber objects stored in an NSMutableArray. I am attempting to perform a calculation on each object in the array. What I want to do is: 1) Take a random higher number variable and keep subtracting a smaller number variable in increments until the value of the variable is equal to the value in the array. For example: NSMutableArray object is equal to 2.50. I have an outside variable of 25 that is not in the array. I want to subtract 0.25 multiple times from the variable until I reach less than or equal to 2.50. I also need a parameter so if the number does not divide evenly and goes below the array value, it resorts to the original array value of 2.50. Lastly, for each iteration, I want to print the values as they are counting down as a string. I was going to provide code, but I don't want to make this more confusing than it has to be. So my output would be: VALUE IS: 24.75 VALUE IS: 24.50 VALUE IS: 24.25 … VALUE IS: 2.50 END

    Read the article

  • UIDocumentInteractionController change title of presented view

    - by whatdoesitallmean
    I am using the UIDocumentInteractionController to display pdf files. My files are stored in the filesystem using encoded filenames that are not user-friendly. I do have access to a more friendly name for the file, but the file is not stored with this name (for uniqueness reasons). When I load the document into the UIDocumentInteractionController then the view displays the unfriendly 'real' filename in the titlebar. Is there any way to change the displayed title as presented by the UIDocumentInteractionController? Thanks.

    Read the article

  • iPhone memory management: a release after setting self.someProperty = nil

    - by ddawber
    I am reading the LazyTableImages code that Apple have released and they do something to this effect (in an NSOperation subclass): - (void)dealloc { [myProperty release]; [myProperty2 release]; } - (void)main { // // Parse operation undertaken here // self.myProperty = nil; self.myProperty2 = nil; } My thinking is that they do this in case dealloc is called before setting properties to nil. Is my thinking correct here? Are the releases unnecessary, as self.myProperty = nil effectively releases myProperty? One thing I have noticed in this code is that they don't release all retained objects in dealloc, only some of them, which is really the cause for my confusion. Cheers

    Read the article

  • Custom inputAccessoryView push my UITableView first row partially off the screen

    - by TonyMocha
    Hi For my scenario, I have a UITableView with a UITextField for the first row. While I try to set custom toolbar for keyboard with UITextField.inputAccessoryView, it pushed my first row of textfield partially off the screen. This is not happening if I avoid adding the toolbar. Refer screen shot below: I tried with NSNotification with keyboardWillShow by reposition to first row of the tableview, but it just look awkward for the table pulling out and in. It might be something to do overriding UITableView/UIScrollView, but I am out of idea how to do this. Would like to know how you guys resolve this. Thanks you!

    Read the article

  • Is it possible to make an alarm using NSTimer and UIDatepicker?

    - by user557425
    I have an app which plays some ambient noises. I have fitted it with a sleep timer and a local notifier which work fine, but the notifier will only fire when the app is in the background. I would like to be able to fit a standard alarm clock that the user can set using the date picker, ie, the user picks 07:15 am on the date picker and this triggers a sound being played at this time. Can this be done?

    Read the article

  • Added CAGradientLayer, getting this in my UIView dealloc: [CALayer release]: message sent to deallocated instance

    - by developerdoug
    Here there, I have a custom UIView. This view acts as a activity indicator but as label above the UIActivityIndicatorView. In the init, I add a CAGradientLayer. I allocate and initialize it and insert it at index 0 as a sublayer of the UIView layer property. In my dealloc method was called, I received a message in the console: - [CALayer release]: message sent to deallocated instance. My code: @interface LabelActivityIndicatorView () { UILabel *_label; UIActivityIndicatorView *_activityIndicatorView; CAGradientLayer *_gradientLayer; } @end @implementation LabelActivityIndicatorView //dealloc - (void) dealloc { [_label release]; [_activityIndicatorView release]; //even tried to remove the layer [_gradientLayer removeFromSuperLayer]; [_gradientLayer release]; [super dealloc]; } // init - (id) initWithFrame:(CGRect)frame { if ( (self = [super initWithFrame:frame]) ) { // init the label // init the gradient layer _gradientLayer = [[CAGradientLayer alloc] init]; [_gradientLayer setBounds:[self bounds]]; [_gradientLayer setPosition:CGPointMake(frame.size.width/2, frame.size.height/2)]; [[self layer] insertSublayer:_gradientLayer atIndex:0]; [[self layer] setNeedsDisplay]; } return self; } @end Anyone have any ideas. Since I'm allocating and initializing the gradient layer I'm responsible for releasing it. I should be able to alloc and init and assign to some ivar. Perhaps I should create a property with retain on it. Thanks,

    Read the article

  • NSData in CoreData is not saving properly

    - by abisson
    I am currently trying to store images I download from the web into an NSManagedObject class so that I don't have to redownload it every single time the application is opened. I currently have these two classes. Plant.h @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) PlantPicture *picture; PlantPicture.h @property (nonatomic, retain) NSString * bucketName; @property (nonatomic, retain) NSString * creationDate; @property (nonatomic, retain) NSData * pictureData; @property (nonatomic, retain) NSString * slug; @property (nonatomic, retain) NSString * urlWithBucket; Now I do the following: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { PlantCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; Plant *plant = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.plantLabel.text = plant.name; if(plant.picture.pictureData == nil) { NSLog(@"Downloading"); NSMutableString *pictureUrl = [[NSMutableString alloc]initWithString:amazonS3BaseURL]; [pictureUrl appendString:plant.picture.urlWithBucket]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:pictureUrl]]; AFImageRequestOperation *imageOperation = [AFImageRequestOperation imageRequestOperationWithRequest:request success:^(UIImage *image) { cell.plantImageView.image = image; plant.picture.pictureData = [[NSData alloc]initWithData:UIImageJPEGRepresentation(image, 1.0)]; NSError *error = nil; if (![_managedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); } }]; [imageOperation start]; } else { NSLog(@"Already"); cell.plantImageView.image = [UIImage imageWithData:plant.picture.pictureData]; } NSLog(@"%@", plant.name); return cell; } The plant information is present, as well as the picture object. However, the NSData itself is NEVER saved throughout the application opening and closing. I always have to REDOWNLOAD the image! Any ideas!? [Very new to CoreData... sorry if it is easy!] thanks!

    Read the article

  • AspectFit Not Working for Transformed UIImageView

    - by Dex
    I have a UIImageView inside a subview and I'm trying to get an AspectFit content mode working how I want for a 90 degree transformation. Here is a demo app of what I mean https://github.com/rdetert/image-scale-test If you run the app and hold it in a landscape orientation (app runs in landscape) you'll see that the image does not stretch from left edge to right edge. What seems to be happening is that the AspectFit works correctly for the portrait/default orientation, but then the image simply gets rotated the image after the fact. How can I make it auto stretch? I think the fact that it is inside a subview may have something to do with it?

    Read the article

  • 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

  • Animate screen while loading textures

    - by Omega
    My RPG-like game has random battles. When the player enters a random battle, it is necessary for my game to load the textures used within that battle (animated monsters, animations, etc). The textures are quite a lot, and rather big (the battles are very graphical intensive). Such process consumes significant time. And while it is loading, the whole screen freezes. The game's map freezes, and the wait time is significant - I personally find it annoying. I can't afford to preload the textures because, after doing some math, I realized: If I preload all the textures at the beginning of the game, the application will definitely crash. If I preload the textures that are used in a specific map when the player enters the map, the application is very likely to crash as well. I can only afford to load the textures when I need them, and dispose of them as soon as the battle ends. I'd prefer to not use a "loading screen" image because it affects my game's design and concept. I want to avoid this approach. If I could do some kind of animation while loading the textures, it would be great, which leads to my question: is that possible? What kind of animation, you ask? Well, how about... you remember when Final Fantasy used to distort the screen while apparently loading the textures? Something like that. But well, distorting is quite a time-consuming process as well, so maybe just a cool frame-by-frame animation or something. While writing this, I realized that I could make small pauses between textures (there are multiple textures), and during such pauses, I update the screen to represent the animation's state. However, this is very unlikely to happen, because each texture is 2048x2048, so the animation would be refreshed at a rather laggy (and annoying) rate. I'd prefer to avoid this as well.

    Read the article

  • What is the proper way to change the UINavigationController transition effect

    - by Felipe Sabino
    I have seen lots of people asking on how to push/pop UINavigationControllers using other animations besides the default one, like flip or curl. The problem is that either the question/answer was relative old, which means the have some things like [UIView beginAnimations:] (example here) or they use two very different approaches. The first is to use UIView's transitionFromView:toView:duration:options:completion: selector before pushing the controller (with the animation flag set to NO), like the following: UIViewController *ctrl = [[UIViewController alloc] init]; [UIView transitionFromView:self.view toView:ctrl.view duration:1 options:UIViewAnimationOptionTransitionFlipFromTop completion:nil]; [self.navigationController pushViewController:ctrl animated:NO]; Another one is to use CoreAnimation explicitly with a CATransaction like the following: // remember you will have to have the QuartzCore framework added to your project for this approach and also add <QuartzCore/QuartzCore.h> to the class this code is used CATransition* transition = [CATransition animation]; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; transition.duration = 1.0f; transition.type = @"flip"; transition.subtype = @"fromTop"; [self.navigationController.view.layer removeAllAnimations]; [self.navigationController.view.layer addAnimation:transition forKey:kCATransition]; UIViewController *ctrl = [[UIViewController alloc] init]; [self.navigationController pushViewController:ctrl animated:NO]; There are pros and cons for both approaches. The first approach gives me a much cleaner code but restricts me from using animations like "suckEffect", "cube" and others. The second approach feels wrong just by looking at it. It starts by using undocumented transitions types (i.e. not present in the Common transition types documentation from CATransition Class Reference) which might get your app rejected from App Store (I mean might as I could not found any reference of apps being rejected because it was using this transactions, which I would also appreciate any clarification on this matter), but it gives you much more flexibility on your animations, as I can use other animation types such as "cameraIris", "rippleEffect" and so on. Regarding all that, do I really need to appeal for QuartzCore and CoreAnimation whenever I need a fancier UINavigationController transition? Is there any other way to accomplish the same effect using only UIKit? If not, will the use of string values like "flip" and "cube" instead of the pre-defined constants (kCATransitionFade, kCATransitionMoveIn, etc...) be an issue regarding my app approval in the App Store? Also, are there other pros and cons regarding both approaches that could help me deciding whether to choose each one of them?

    Read the article

< Previous Page | 51 52 53 54 55 56 57 58 59 60 61 62  | Next Page >