w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
UIImage name in xibs issue: should I use @2x
You need to set great_image.png in xib.Because it will take @2x image if it is in retina dispaly. if you don't have great_image.png image in your project in that case it will not display in non-retina device

Categories : Iphone

UIImage isKindOfClass issue
Yes, you need to allocate memory to your UIImage. What is basically happening is that your image is being temporarily stored in the memory and deallocated upon closing the app so iOS could allocate that memory to more immediate needs. You can fix that as below. I'm also gonna allocate a string since stringWithFormat returns an autorelease String. NSString *imageName = [[NSString alloc] initWithFormat::@"%@.png",[pages objectAtIndex:swipeCount]]; UIImage *myImage = [UIImage imageNamed:myImage]; [imageview setImage:image];

Categories : Iphone

UIImage resize performance and quality issue
All native API suppose you to use image.png and image@2x.png, so it may be difficult sometimes to use just one image and scale it depending on retina/non-retina. Moreover using retina graphics on non-retina devices lead to more extensive use of these devices' resource causing battery drain. And, of course, if you have many images, that will decrease performance of your application. In other words there are reasons to use double set of images and you should better use it instead of one large image being scaled.

Categories : IOS

UIImage orientation issue when calling UIImageJPEGRepresentation
Because the UIImageJPEGRepresentation of a UIImage discards much of the UIImage metadata, including the imageOrientation info. You have to add the orientation info back after converting to JPEG but before you store the image. Otherwise, all your JPEGs will report that they are oritented Up. Now how to actually add that, I don't know... start with How to write orientation data to the UIImage iOS SDK and Problem setting exif data for an image and iOS UIImagePickerController result image orientation after upload

Categories : Misc

Can I create 2 XIBs for one view?
you can create two view inside the same nib/xib file and add particular view on click Segemented control One view already has outlet in controller class and for other view create a IBOutlet and use.

Categories : Iphone

Working with Mvvmcross and Xibs
From the trace the 'doesn't start' issue is to do with: Object reference not set to an instance of an object at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel I'm not sure what's causing that - it's hard to tell from the trace and description - if you put a sample project somewhere then someone from mvx can take a look. Alternatively there are a few more up to date videos for working with XIBs These are contained in this N+1 index - http://mvvmcross.wordpress.com In particular, see: FirstView/XIB work starting at 22:40 in http://www.youtube.com/watch?feature=player_detailpage&v=UC2r4mmj3UI#t=22m40 Several views in http://www.youtube.com/watch?v=h0Eww89c9DM&feature=youtube_gdata (although not sure why I said I couldn't build on the Mac at the time - may

Categories : Iphone

Wiring NSToolBarItem with XIBs
The delegate class does not know the selector you've wired. Either your delegate is wrong or you've got a typing error in your method. Check the signature of the Method you've declared in your headerfile vs. its implementation in the class file. Perhaps you forgot to declare a parameter. edit: the class type where the selector is called looked weird, so I googled __nscftype unrecognized selector. here are some suggestions, it seems like your delegate is already disposed : http://imlocation.wordpress.com/2007/09/13/strange-objects-nscftype-indicate-memory-management-bugs/ [__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80

Categories : Objective C

How to load UIImage to UICollectionView from an array of UIImage
I think you didn't set tag to your UIImageView object,so when you are trying to access your UIImageView using viewWithTag it returns nothing. UIImageView *img =[[UIImageView alloc]initWithImage:self.image]; img.tag = 100; [insetView addSubview:img]; self.layer.shouldRasterize = YES; I hope it will work.

Categories : IOS

ios: UIImage scale, UIImage and his appropriate CGimage are not identical
//This method will resize the original image to desired width //maintaining the Aspect Ratio -(UIImage*)getResizedToWidth:(CGFloat)width { UIImage *resultImage = nil; CGFloat ar = self.size.width/self.size.height; CGFloat ht = width/ar; CGSize newSize = CGSizeMake(width, ht); UIGraphicsBeginImageContext(newSize); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextScaleCTM(ctx, 1, -1); CGContextTranslateCTM(ctx, 0, -newSize.height); CGRect imageRect = CGRectMake(0, 0, newSize.width, newSize.height); CGContextDrawImage(ctx, imageRect, self.CGImage); resultImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return resultImage; } //This method will resize the original image to desired height //

Categories : IOS

Should one stop loading UIView from xibs?
You should only use child view controllers when you are building custom container view controllers, or your layout is very complex. Now for my opinion: I always use storyboards, because they allow you to express an entire screen all at design time without having to assemble it (like your code above) at runtime. So, even if you choose to use a storyboard for each individual view controller (some large teams do this to avoid merge problems), you can have all of your views and view controller laid out and connected together. If you are looking to create a dynamic number of a certain view at runtime, I probably would just code the view, or if its very complex, I'd store an NSNib in an ivar and instantiate each view from it. Bottom line: child view controllers in no way replace or are even

Categories : IOS

need of two xibs for my portrait and landscape modes
The answer is NO . You need not use 2 Xib's. Please go through the following links :- Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape? Different Xib's for Potrait and Landscape mode for iPad http://www.theappcodeblog.com/2011/03/30/orientation-change-tutorial-change-the-view-when-the-orientation-changes/ Also ios 6 offers new methods like shouldAutoRotate etc. You might want to go through them too.

Categories : Iphone

Naming convention for xibs 3.5inch and 4inch
+ (NSString *)getNibNameForName:(NSString *)name { if (IsiPhone4Inch) { NSString *possibleNibName = [NSString stringWithFormat:@"%@_iPhone4Inch", name]; if ([[NSBundle mainBundle] pathForResource:possibleNibName ofType:@"nib"] != nil) { return possibleNibName; } } return [NSString stringWithFormat:IS_IPAD ? @"%@_iPad":@"%@", name]; }

Categories : IOS

Problems with multiple xibs for rotation under iOS6
This is how I do it and it works on iOS 5+: - (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkBagRotation) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; [self checkBagRotation]; } - (void)checkBagRotation { orientation = [UIApplication sharedApplication].statusBarOrientation; if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { [[NSBundle mainBundle] loadNibNamed:@"Controller-landscape" owner:self options:nil]; } else {

Categories : IOS

How to disable Xcode 5 automatically upgrade xibs to iOS7 appearance
In the File Inspector for the xib (cmd-opt-1), you can change the "Opens in" popup to say "Xcode 4.6". This will revert the document format to one that is compatible with Xcode 4.6, but it also means you will not be able to take advantage of some of the new capabilities in Xcode with regards to xibs. If you want to "reset" the "Always upgrade" choice you made, you can do that by resetting that particular user default using Terminal: defaults write com.apple.dt.xcode IBAlwaysUpgradeAutolayoutDocuments -bool false

Categories : Xcode

iPhone->iPad Porting. How to reposition programmable elements like buttons and labels (NOT XIBs)
it seemed to be difficult task, however, I had some success with xibs (they look OK on iPad simulator) xib are the first steps, than the .m files. Sad to say, all the programmable elements like buttons, labels and custom images are placed at the iPhone-coded positions They are hardcoded into source like : [button setFrame:CGRectMake(320, 0, 100,100 )]; How can I convert the positions of these elements to iPad-compatible ones? You have to check which is running now: iPhone or iPad. Here is how. If iphone let be the old code, if iPad close yur eyes and do math in order to get the new coordinates. I hope it helps somebody!

Categories : Iphone

how to use [UIImage resizableImageWithCapInsets:]
Use this function, you can change the size of UIImage using this function. + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize { UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } Hope this will help you.

Categories : IOS

UIImage Not being Set from NSData
Assuming the string containing the base 64 encoded is good, your code looks OK. I would look at the dataFromBase64String method to see if that is causing the problem. Here is a version I use based on some else's work: -(NSData *)dataFromBase64EncodedString:(NSString *)string{ if (string.length > 0) { //the iPhone has base 64 decoding built in but not obviously. The trick is to //create a data url that's base 64 encoded and ask an NSData to load it. NSString *data64URLString = [NSString stringWithFormat:@"data:;base64,%@", string]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:data64URLString]]; return data; } return nil; } You could add a NSData category with this method to make its use very convenient.

Categories : Iphone

UIImage from AVCaptureSession
Here's a tech note describing exactly what you want to achieve: How to capture video frames from the camera as images using AV Foundation on iOS

Categories : IOS

How to know if a UIImage is representable in PNG or JPG?
go to following link... How to check if downloaded PNG image is corrupt? it may help you... Let me know it is working or not... Happy Coding!!!!

Categories : Iphone

How to use resizableImageWithCapInsets on UIImage?
Use the following code to stretch the image on iOS 6+: [[[UIImage imageNamed:@"background.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(1.f, 1.f, 1.f, 1.f) resizingMode:UIImageResizingModeStretch] drawInRect:rect];

Categories : Iphone

Displaying UIImage
Try to use this one.You know you can't get IBOutlet on UIImage. So you need to write UIImageView instead of UIImage. @property(nonatomic,retain) IBOutlet UIImageView* image ;

Categories : Iphone

How to use UIImage+SDAdditions
self.collectedImage = image; NSLog(@"--------------------collected image information----------------------"); NSLog(@"the collected image orientation is: %i",image.imageOrientation); NSLog(@"the image width is: %f",self.collectedImage.size.width); NSLog(@"the image height is: %f",self.collectedImage.size.height); // scale the image UIImage *newCollectedImage = [self.collectedImage scaleWithMaxDimension:([[UIScreen mainScreen] bounds].size.height)]; self.collectedImage = newCollectedImage; NSLog(@"--------------------collected NEW image information----------------------"); NSLog(@"the new collected image orientation is: %i",self.collectedImage.imageOrientation); NSLog(@"the new image width is: %f",self.collectedImage.size.width); NSLog(@"the new image height is: %f",self.collectedImage.siz

Categories : IOS

Can't set UIImage to UIImageView from Url?
Presumably imgAlbum1 is an outlet to your existing image view. Instead of that last line, which tries to create a new image view without displaying it anywhere, you probably want: self.imgAlbum1.image = image;

Categories : Iphone

CAShapeLayer and UIImage
CAShapeLayer is good for masking, but your needs are more than just masking. You would need to deform the image what is not simple and may not be achievable by CAShapeLayers. There are some options.. First (the hard one): Draw (via -(void)drawRect:(CGRect)rect ) your marker by code respectively to the black dot. And then animate the change via a simple CoreAnimation animation. Second (the easy one): Create a Sequence of images and start the animation like this: NSArray * imageArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], [UIImage imageNamed:@"3.png"], [UIImage imageNamed:@"4.png"], [UIImage imageNamed:@

Categories : IOS

Compressing UIImage as Far as Possible?
You should probably grab a smaller version of the image. See this question for a good example of how to resize a UIImage. How to scale down a UIImage and make it crispy / sharp at the same time instead of blurry?

Categories : IOS

Resizable UIImage
Check this out: Resizable UIImage where outside stretches and inside is kept the same Basically the opposite of what you want. Hope it helps!

Categories : IOS

How to convert CCSprite to UIImage
Here is the solution on how to convert CCSprite to UIImage: http://www.cocos2d-iphone.org/forums/topic/convert-ccspriteframe-to-uiimage-is-this-possible/ Give it a look here and see if it can help you. This is the solution from the forum (link above): just create a sprite like how you would usually do using spritesheets like so: CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:"thumbnail5.png"]; then use this method to get an UIImage from a sprite - (UIImage *) renderUIImageFromSprite CCSprite *)sprite { int tx = sprite.contentSize.width; int ty = sprite.contentSize.height; CCRenderTexture *renderer = [CCRenderTexture renderTextureWithWidth:tx height:ty]; sprite.anchorPoint = CGPointZero; [renderer begin]; [sprite visit]; [renderer end]; return [renderer getUIImag

Categories : IOS

UIImage imageWithData: does not release under ARC
You are retaining UIImageView instance twice. First when you create it using alloc and then when it is inserted to another view (insertSubview). That parent view will retain it. Insert: [imageView release]; after the line: [self insertSubview:imageView atIndex:0]; EDITED: If you are using ARC then my answer is not valid. Please ignore it.

Categories : Objective C

How to return an UIImage type from a GCD
First of all, I would recommend you to read about blocks in Objective C. The dispatch_async block you are using inside your function is async and thus it returns immediately after you use it, as it runs in it's own pool. For proper use, you can call another method to return the image processes inside the block, or post NSNotification when your image is ready. like this: -(void) ComLog { ExibitorInfo *currentExibitor100 = [[ExibitorInfo alloc] init]; currentExibitor100 = [self.exibitorsArray objectAtIndex:0]; imageQueueCompanyLogo = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); dispatch_async(imageQueueCompanyLogo, ^ { UIImage *imageCompanyLogo = [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:[currentExibitor100 compa

Categories : IOS

Save UItextfield on UIImage
UIGraphicsBeginImageContext(self.yourView.bounds.size); [self.yourView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *shareImage = UIGraphicsGetImageFromCurrentImageContext(); shareImage is UIImage , you can share and save it .. hope it can help you.

Categories : Iphone

UIImage - imageWithContentsOfFile: vs initWithContentsOfFile
The first returns an autoreleased object. There is a high chance that the imageWithContentsOfFile: version invokes the standard constructor, so there shouldn't be any noticeable difference in speed/efficiency. Both perform and are used the same way in an ARC environment.

Categories : IOS

Converting UIImage into NSData
You are converting your image to a PNG representation and then you rename it image.JPG IE might get confused by that. Try to either rename your image to image.PNG or use UIImageJPEGRepresentation

Categories : IOS

How to fit uiimage from camera after cropping?
Sample Code : [imageView setContentMode:UIViewContentModeTopLeft]; [imageView setClipsToBounds:YES]; Content Modes : Look at Documetation typedef enum { UIViewContentModeScaleToFill, UIViewContentModeScaleAspectFit, UIViewContentModeScaleAspectFill, UIViewContentModeRedraw, UIViewContentModeCenter, UIViewContentModeTop, UIViewContentModeBottom, UIViewContentModeLeft, UIViewContentModeRight, UIViewContentModeTopLeft, UIViewContentModeTopRight, UIViewContentModeBottomLeft, UIViewContentModeBottomRight, } UIViewContentMode;

Categories : Iphone

iOS - Invert a UIImage with button
I see the negetiveImage method has a lot of code. Here's a simple one using Core Image filters. Include Core Image Framework to your project Import the core Image header. #import <CoreImage/CoreImage.h> The below code should return you the inverted UIImage UIImage *inputImage = [UIImage imageNamed:@"imageName"]; CIFilter* filter = [CIFilter filterWithName:@"CIColorInvert"]; [filter setDefaults]; [filter setValue:inputImage.CIImage forKey:@"inputImage"]; UIImage *outputImage = [[UIImage alloc] initWithCIImage:filter.outputImage]; The outputImage will be inverted

Categories : Iphone

UIImage PNG Opacity adjustment
If you're creating the PNG in an image editing software, please make sure you've encoded the transparency while creating the image. Sometimes some image editors have an option for 'saving transparency' that's unchecked by default, when you're exporting something as a PNG. Other than that, any transparency on a PNG will show up on a UIButtonTypeCustom. You don't need to do anything special to preserve transparency on a UIImage that's loading up a PNG. Before you use the image in the code, please open it in Preview to make sure the transparency is present. Oh and to answer your other question, UIImage does not have any properties relating to transparency. The closest thing you have is the alpha property for a UIView but even that simply changes the overall opacity of your UIView. EDIT: M

Categories : IOS

UIImage nonlinear resizing
A few ideas: Copy parts of the UIImage into different CGContext using CGBitmapContextCreateImage(), copy the parts around, scale individually, put back together. Use CIFilter effects on parts of your Image, masking the parts you want to scale. (Core Image Programming Guide)

Categories : IOS

How to get location of a specified color in an UIImage?
Add UIImage-Utils to your project. Then get the color of x,y like this: CGFloat imageWidth = image.size.width; NSData *imageData = [UIImage bytesFromImage:image] Byte *bytes = (Byte *)imageData.bytes; CGFloat red = bytes[redOffset (x, y, imageWidth)] / 255.0f; CGFloat green = bytes[greenOffset (x, y, imageWidth)] / 255.0f; CGFloat blue = bytes[blueOffset (x, y, imageWidth)] / 255.0f; UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0f]; Store the x,y of the colors matching the color you are looking for. Repeat for every x,y in the image.

Categories : IOS

How to assign a UIimage while within a block
Try to run these block of code in main thread as it appeared you are trying to set the image and updating layout in background thread. Use following NSThread method right after UIImage *imager = [UIImage imageWithData:image] [self performSelectorOnMainThread:@selector(updateImage:) withObject:imager waitUntilDone:false]; // Define method to update the image - (void)updateImage: (UIImage *)paramImage { cell.correctImage.image = paramImage; [cell layoutIfNeeded]; }

Categories : IOS

Convert UIImage to 8 bits
Following code will work for images without alpha channel: CGImageRef c = [[UIImage imageNamed:@"100_3077"] CGImage]; size_t bitsPerPixel = CGImageGetBitsPerPixel(c); size_t bitsPerComponent = CGImageGetBitsPerComponent(c); size_t width = CGImageGetWidth(c); size_t height = CGImageGetHeight(c); CGImageAlphaInfo a = CGImageGetAlphaInfo(c); NSAssert(bitsPerPixel == 32 && bitsPerComponent == 8 && a == kCGImageAlphaNoneSkipLast, @"unsupported image type supplied"); CGContextRef targetImage = CGBitmapContextCreate(NULL, width, height, 8, 1 * CGImageGetWidth(c), CGColorSpaceCreateDeviceGray(), kCGImageAlphaNone); UInt32 *sourceData = (UInt32*)[((__bridge_transfer NSData*) CGDataProviderCopyData(CGImageGetDataProvider(c))) bytes]; UInt

Categories : IOS

UIImage from GRKPhoto using ALAsset
Usually CALayerInvalidGeometry and NAN results from invalid setting of CALayer frame, which in turn can be set by view.frame. It maybe that somewhere the layer position / transform is being set incorrectly. Since you are not doing this directly it seems to be a bug with Grabkit. File it here. You can consider going inside CGImageRef imgRef = [[asset defaultRepresentation] fullResolutionImage]; using F7 to provide more information about the crash to Grabkit.

Categories : IOS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.